-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] install fails with --offline and --global #3764
Comments
My team is experiencing the same issue, where a TGZ fails to install with the This is an important use case for us, to be able to globally install a CLI package without an Internet connection, since some customers are behind a restrictive firewall or proxy. I've created a minimal sample repo that uses GitHub Actions to demonstrate the issue. The same package is being installed on Windows/Linux/macOS, and you can see in the output of the "Download and Verify" step that all dependencies (including |
Nice, maybe this will help to gain more visibility. I've been digging through the npm source code to try to figure out what's going on: as best as I can tell, this has something to do with non- I did find that adding |
The reason for this error is because the tarball is not the only thing that is fetched by npm during install. When you install $ npm info ms dist.tarball
https://registry.npmjs.org/ms/-/ms-2.1.3.tgz If you need $ npm info ms dist.tarball
https://registry.npmjs.org/ms/-/ms-2.1.3.tgz ~/D/n/scratch $ npm cache ls --cache ./failure/cache/
pacote:tarball:file:../../../debug-4.3.2.tgz
pacote:tarball:file:../../../ms-2.1.2.tgz
pacote:tarball:file:debug-4.3.2.tgz
pacote:tarball:file:ms-2.1.2.tgz
|
~/D/n/scratch $ rm -rf ./failure/
~/D/n/scratch $ npm cache add debug --prefix ./failure/prefix/ --cache ./failure/cache
~/D/n/scratch $ npm cache add ms@2.1.2 --prefix ./failure/prefix/ --cache ./failure/cache
~/D/n/scratch $ npm --global --prefix ./failure/prefix --cache ./failure/cache --no-audit --offline --ddd install debug
npm verb cli [
npm verb cli '/Users/wraithgar/.nvm/versions/node/v16.13.2/bin/node',
npm verb cli '/Users/wraithgar/.nvm/versions/node/v16.13.2/bin/npm',
npm verb cli '--global',
npm verb cli '--prefix',
npm verb cli './failure/prefix',
npm verb cli '--cache',
npm verb cli './failure/cache',
npm verb cli '--no-audit',
npm verb cli '--offline',
npm verb cli '--ddd',
npm verb cli 'install',
npm verb cli 'debug'
npm verb cli ]
npm info using npm@8.1.2
npm info using node@v16.13.2
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 1ms
npm timing config:load:file:/Users/wraithgar/.nvm/versions/node/v16.13.2/lib/node_modules/npm/npmrc Completed in 1ms
npm timing config:load:builtin Completed in 1ms
npm timing config:load:cli Completed in 2ms
npm timing config:load:env Completed in 0ms
npm timing config:load:file:/Users/wraithgar/Development/npm/scratch/failure/prefix/.npmrc Completed in 0ms
npm timing config:load:project Completed in 0ms
npm timing config:load:file:/Users/wraithgar/.npmrc Completed in 2ms
npm timing config:load:user Completed in 2ms
npm timing config:load:file:/Users/wraithgar/Development/npm/scratch/failure/prefix/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 0ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:credentials Completed in 1ms
npm timing config:load:setEnvs Completed in 1ms
npm timing config:load Completed in 8ms
npm timing npm:load:configload Completed in 9ms
npm timing npm:load:setTitle Completed in 16ms
npm timing npm:load:setupLog Completed in 1ms
npm timing config:load:flatten Completed in 2ms
npm timing npm:load:cleanupLog Completed in 2ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load:projectScope Completed in 1ms
npm timing npm:load Completed in 35ms
npm timing arborist:ctor Completed in 1ms
npm timing idealTree:init Completed in 3ms
npm timing idealTree:userRequests Completed in 1ms
npm sill idealTree buildDeps
npm sill fetch manifest debug@*
npm http fetch GET 200 https://registry.npmjs.org/debug 11ms (cache hit)
npm sill placeDep ROOT debug@4.3.3 OK for: want: *
npm sill fetch manifest ms@2.1.2
npm http fetch GET 200 https://registry.npmjs.org/ms 4ms (cache hit)
npm timing idealTree:#root Completed in 23ms
npm sill placeDep node_modules/debug ms@2.1.2 OK for: debug@4.3.3 want: 2.1.2
npm timing idealTree:node_modules/debug Completed in 2ms
npm timing idealTree:node_modules/debug/node_modules/ms Completed in 0ms
npm timing idealTree:buildDeps Completed in 26ms
npm timing idealTree:fixDepFlags Completed in 1ms
npm timing idealTree Completed in 32ms
npm timing reify:loadTrees Completed in 33ms
npm timing reify:diffTrees Completed in 0ms
npm sill reify moves {}
npm timing reify:retireShallow Completed in 0ms
npm timing reify:createSparse Completed in 3ms
npm timing reify:loadBundles Completed in 0ms
npm timing reifyNode:node_modules/debug/node_modules/ms Completed in 16ms
npm timing reifyNode:node_modules/debug Completed in 17ms
npm timing reify:unpack Completed in 17ms
npm timing reify:unretire Completed in 0ms
npm timing build:queue Completed in 0ms
npm timing build:deps Completed in 0ms
npm timing build Completed in 1ms
npm timing reify:build Completed in 1ms
npm timing reify:trash Completed in 0ms
npm timing reify Completed in 73ms
npm sill ADD node_modules/debug
npm sill ADD node_modules/debug/node_modules/ms
added 2 packages in 254ms
npm timing command:install Completed in 76ms
npm verb exit 0
npm timing npm Completed in 255ms
npm info ok Note the full urls in the tarballs npm cache ls --cache ./failure/cache/
make-fetch-happen:request-cache:https://registry.npmjs.org/debug
make-fetch-happen:request-cache:https://registry.npmjs.org/debug/-/debug-4.3.3.tgz
make-fetch-happen:request-cache:https://registry.npmjs.org/ms
make-fetch-happen:request-cache:https://registry.npmjs.org/ms/-/ms-2.1.2.tgz
pacote:tarball:debug@
pacote:tarball:ms@2.1.2 |
Is there an existing issue for this?
Current Behavior
I am trying to write a gentoo ebuild to install npm packages. In order to do so, I need to perform all network operations prior to calling
npm install
, thus I am using the--offline
option. However, if I pair this with--global
, I get an error because npm tries to fetch a dependency (even though I have already installed it).Expected Behavior
I expect to be able to install packages using both
--offline
and--global
Steps To Reproduce
The following will reproduce the issue in a sub-directory called 'failure', and show how removing the
--global
flag fixes the issue in a sub-directory called 'success'The error that I see is the following (this is a snippet of the full output):
Environment
As I've been reviewing the npm code base, I think the following from the arborist dependency provides a clue:
I added a bit of debugging to the
make-fetch-happen
dependency, which is further up the stack chain. Specifically, I was curious about theoptions
parameter passed to thefetch
function - I wanted to see if it differed at all with/without the--global
flag.What I found is the following:
I'm not quite sure what to make of this though. The final clue that I found (but again, not quite sure what to make of it) is this comment back in the
arborist
code:I don't understand why this "pre-fetch" is occuring for the
--global
case only.The text was updated successfully, but these errors were encountered: