[solved] "npm i" works in local node:11 but fails in drone:1.0.0-rc.2

I just spent hours trying to nail down a very strange issue with no luck:

Here is my .drone.yml:

pipeline:
  build:
    image: node:11
    commands:
      - npm i git+https://code.gitea.me/org/my-package.git#ba271ee8b5e2e0f1ffe661ff1a10259ce56f832b --verbose

It fails in drone with code ENOVERSIONS npm ERR! No valid versions available for my-package.

In local, I did:

docker pull node:11
docker run -it --entrypoint bash node:11
nano ~/.netrc # adding gitea app password
npm i git+https://code.gitea.me/org/my-package.git#ba271ee8b5e2e0f1ffe661ff1a10259ce56f832b --verbose

It works fine! both are using exact same image, exact same node/npm version.

Looking at the full logs (below), one can see that in drone, npm install command will search for “my-package” on npm registry (https://registry.npmjs.org/my-package) and won’t find a version of course, as I never published this package. But it should never crawl the npm registry!! The package I want to install is located in a private git repo (gitea). When running in drone:11 docker image, it works just fine…!!!

It’s not an authentication issue, as I can perfectly git clone the my-package repo in drone.

Is that a bug of the V1?

Thank you for your help,

Best,

Full drone logs [FAILURE]:

npm i git+https://code.gitea.me/org/my-package.git#ba271ee8b5e2e0f1ffe661ff1a10259ce56f832b --verbose
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'i',
npm verb cli 'git+https://code.gitea.me/org/my-package.git#ba271ee8b5e2e0f1ffe661ff1a10259ce56f832b',
npm verb cli '--verbose' ]
npm info using [[email protected]](mailto:[email protected])
npm info using [[email protected]](mailto:[email protected])
npm verb npm-session abb93897cc9f7005
npm info lifecycle [[email protected]~prepack](mailto:[email protected]~prepack): [[email protected]](mailto:[email protected])
npm info lifecycle [[email protected]~postpack](mailto:[email protected]~postpack): [[email protected]](mailto:[email protected])
npm timing stage:loadCurrentTree Completed in 2259ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
npm http fetch GET 200 https://registry.npmjs.org/my-package 132ms
npm timing stage:rollbackFailedOptional Completed in 1ms
npm timing stage:runTopLevelLifecycles Completed in 2595ms
npm verb type version
npm verb stack my-package: No valid versions available for my-package
npm verb stack at pickManifest (/usr/local/lib/node_modules/npm/node_modules/npm-pick-manifest/index.js:20:11)
npm verb stack at fetchPackument.then.packument (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/manifest.js:39:14)
npm verb stack at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
npm verb stack at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
npm verb stack at Promise._settlePromise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
npm verb stack at Promise._settlePromise0 (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
npm verb stack at Promise._settlePromises (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
npm verb stack at Async._drainQueue (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
npm verb stack at Async._drainQueues (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
npm verb stack at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
npm verb stack at processImmediate (timers.js:632:19)
npm verb cwd /drone/src
npm verb Linux 4.9.93-mainline-rev1
npm verb argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "git+https://code.gitea.me/org/my-package.git#ba271ee8b5e2e0f1ffe661ff1a10259ce56f832b" "--verbose"
npm verb node v11.4.0
npm verb npm v6.4.1
npm ERR! code ENOVERSIONS
npm ERR! No valid versions available for my-package
npm verb exit [ 1, true ]
npm timing npm Completed in 3648ms
npm ERR! A complete log of this run can be found in:
npm ERR! */root/* .npm/_logs/2018-12-10T17_07_05_063Z-debug.log

Full local logs [SUCCESS]:

npm i git+https://code.gitea.me/org/my-package.git#ba271ee8b5e2e0f1ffe661ff1a10259ce56f832b --verbose
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'i',
npm verb cli 'git+https://code.gitea.me/org/my-package.git#ba271ee8b5e2e0f1ffe661ff1a10259ce56f832b',
npm verb cli   '--verbose' ]
npm info using [email protected]
npm info using [email protected]
npm verb npm-session 92f5e868f57ad6c8
npm info lifecycle [email protected]~prepack: [email protected]
npm info lifecycle [email protected]~postpack: [email protected]
npm timing stage:loadCurrentTree Completed in 2813ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 1ms
npm http fetch GET 200 https://registry.npmjs.org/node-fetch 343ms
npm http fetch GET 200 https://registry.npmjs.org/debug 349ms
npm http fetch GET 200 https://registry.npmjs.org/qs 385ms
npm http fetch GET 200 https://registry.npmjs.org/ws 390ms
npm http fetch GET 200 https://registry.npmjs.org/ms 39ms
npm http fetch GET 200 https://registry.npmjs.org/ms/-/ms-2.1.1.tgz 39ms
npm http fetch GET 200 https://registry.npmjs.org/async-limiter 32ms
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 556ms
npm timing stage:loadIdealTree Completed in 565ms
npm timing stage:generateActionsToTake Completed in 10ms
npm verb correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
npm verb makeDirectory /root/.npm/_locks creation not in flight; initializing
npm timing audit compress Completed in 2ms
npm info audit Submitting payload of 821bytes
npm verb lock using /root/.npm/_locks/staging-781faa38490e6896.lock for /node_modules/.staging
npm http fetch GET 200 https://registry.npmjs.org/debug/-/debug-4.1.0.tgz 68ms
npm http fetch GET 200 https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz 98ms
npm http fetch GET 200 https://registry.npmjs.org/qs/-/qs-6.5.2.tgz 112ms
npm http fetch GET 200 https://registry.npmjs.org/ws/-/ws-6.1.2.tgz 174ms
npm http fetch GET 200 https://registry.npmjs.org/node-fetch/-/node-fetch-2.3.0.tgz 564ms
npm timing action:extract Completed in 610ms
npm timing action:finalize Completed in 7ms
npm timing action:refresh-package-json Completed in 35ms
npm info lifecycle [email protected]~preinstall: [email protected]
npm info lifecycle [email protected]~preinstall: [email protected]
npm info lifecycle [email protected]~preinstall: [email protected]
npm info lifecycle [email protected]~preinstall: [email protected]
npm info lifecycle [email protected]~preinstall: [email protected]
npm info lifecycle [email protected]~preinstall: [email protected]
npm info lifecycle [email protected]~preinstall: [email protected]
npm timing action:preinstall Completed in 2ms
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm timing action:build Completed in 3ms
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~install: [email protected]
npm timing action:install Completed in 2ms
npm info lifecycle [email protected]~postinstall: [email protected]
npm info lifecycle [email protected]~postinstall: [email protected]
npm info lifecycle [email protected]~postinstall: [email protected]
npm info lifecycle [email protected]~postinstall: [email protected]
npm info lifecycle [email protected]~postinstall: [email protected]
npm info lifecycle [email protected]~postinstall: [email protected]
npm info lifecycle [email protected]~postinstall: [email protected]
npm timing action:postinstall Completed in 8ms
npm verb unlock done using /root/.npm/_locks/staging-781faa38490e6896.lock for /node_modules/.staging
npm timing stage:executeActions Completed in 717ms
npm timing stage:rollbackFailedOptional Completed in 2ms
npm timing stage:runTopLevelLifecycles Completed in 4117ms
npm WARN saveError ENOENT: no such file or directory, open '/package.json'
npm info lifecycle undefined~preshrinkwrap: undefined
npm info lifecycle undefined~shrinkwrap: undefined
npm notice created a lockfile as package-lock.json. You should commit this file.
npm info lifecycle undefined~postshrinkwrap: undefined
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm verb enoent This is related to npm not being able to find a file.
npm verb enoent
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.

npm timing audit submit Completed in 1049ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 1050ms
npm timing audit body Completed in 2ms
+ [email protected]
added 7 packages from 7 contributors and audited 7 packages in 4.455s
found 0 vulnerabilities

npm verb exit [ 0, true ]
npm timing npm Completed in 4702ms
npm info ok

so drone basically converts your pipeline to the following, and executes inside the node container:

#!/bin/sh

npm i git+https://code.gitea.me/org/my-package.git#ba271ee8b5e2e0f1ffe661ff1a10259ce56f832b --verbose

Drone really has no control over how npm (running inside node:11) pulls your packages, so I’m not really sure how it could be a Drone bug … but if you have any ideas, I’m open to suggestions.

OMG

I had a package-lock.json commited, so even if running npm install my-package, npm was reading/checking the package-lock.json in the background…invisible in the logs. I git deleted the package-lock.json and BAM…everything works as expected !

Just that I spent 4 hours on this, damn.

Thanks Brad for your quick response, ruling out drone’s fault helped me a lot! :hugs: