Skip to content
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] npm-shrinkwraps not respected for global installs of local packages? #5325

Open
2 tasks done
edvincent opened this issue Aug 18, 2022 · 2 comments
Open
2 tasks done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@edvincent
Copy link

edvincent commented Aug 18, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When globally installing a package that contains an npm-shrinkwrap.json file, it's not respected. It's actually always installing the latest version, just as it the shrinkwrap file wasn't there.

This kind of defeats the purpose its serves - as per https://docs.npmjs.com/cli/v8/configuring-npm/npm-shrinkwrap-json: The recommended use-case for npm-shrinkwrap.json is applications deployed through the publishing process on the registry: for example, daemons and command-line tools intended as global installs.

I was actually looking into moving to use that shrinkwrap file exactly for that in coder/code-server#5071 - vending it installed as a global install with deterministic dependencies - because we had issues with latest releases not being compatible. But realized it doesn't actually work at all...

Expected Behavior

As per https://docs.npmjs.com/cli/v8/configuring-npm/npm-shrinkwrap-json, I'd would expect a global install to use the versions from the shrinkwrap file - even when doing a global install...

When doing a non-global install, it works as expected.

Steps To Reproduce

mkdir test
cd test/
npm init # Saying ok to all defaults
npm install lru-cache@7.10.0
npm shrinkwrap
npm pack
npm install -g test-1.0.0.tgz # Attached this tgz to the issue here too

Resulting tgz: test-1.0.0.tgz

One would expect lru-cache@7.10.0 in the dependencies.

But lru-cache@7.14.0 (at the moment of this writing, the latest version) gets installed:

ubuntu@ip-172-26-4-193:~/test$ npm list -g --depth=10
[...]
└─┬ test@1.0.0
  └── lru-cache@7.14.0

More confirmations:

  • /home/ubuntu/.nvm/versions/node/v16.17.0/lib/node_modules/test/npm-shrinkwrap.json shows lru-cache@7.10.0 as expected
  • /home/ubuntu/.nvm/versions/node/v16.17.0/lib/node_modules/test/node_modules/lru-cache/package.json shows "version": "7.14.0"

Environment

  • npm: 8.18.0 (issue as well with 8.15.0)
  • Node.js: v16.17.0
  • OS Name: Ubuntu 20.02
  • System Model Name: AWS Lightstail Instances
  • npm config:
; "user" config from /home/ubuntu/.npmrc

python = "python3"

; node bin location = /home/ubuntu/.nvm/versions/node/v16.17.0/bin/node
; node version = v16.17.0
; npm local prefix = /home/ubuntu
; npm version = 8.18.0
; cwd = /home/ubuntu
; HOME = /home/ubuntu
; Run `npm config ls -l` to show all defaults.
@edvincent edvincent added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Aug 18, 2022
@edvincent
Copy link
Author

Didn't find an issue for this, the only discussion around shrinkwrap problems seems to be in #4323

Which I actually used as another package to confirm that the shrinkwrap file wasn't doing anything (later versions than the ones listed in the shrinkwrap file are downloaded)...

@edvincent
Copy link
Author

Need a bit more research, but a quick update: this bug seems to only apply to installs done locally. When installing from a remote NPM package, the shrinkwrap file is seems respected... Which is weird because when I installed firebase-tools (from the comment above) it did seem to apply...

@edvincent edvincent changed the title [BUG] npm-shrinkwraps not respected for global installs - completely defeating its purpose? [BUG] npm-shrinkwraps not respected for global installs of local packages? Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

1 participant