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] Packages from private repository added with version '*' #2934

Closed
Lehks opened this issue Mar 24, 2021 · 10 comments · Fixed by npm/arborist#279
Closed

[BUG] Packages from private repository added with version '*' #2934

Lehks opened this issue Mar 24, 2021 · 10 comments · Fixed by npm/arborist#279
Assignees
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@Lehks
Copy link

Lehks commented Mar 24, 2021

Current Behavior:

The packages are beeing added to the dependencies in package.json's with the version *.

This worked in npm version 7.6.3. Also, my Nexus Version is not the latest (OSS 3.17.0-01), so I do not expect it to support the latest npm features. However, I would still consider this a bug in npm, since it worked in the previous version and a minor version update should not break backwards-compatiblity (according to SemVer).

Expected Behavior:

The packages should be added with a concrete version e.g. ^1.0.0.

Steps To Reproduce:

  • npm install my-package (my-package is hosted in a private Sonar Nexus)
  • The dependency is now added to package.json with verison *.

Environment:

  • OS: Ubuntu (WSL 2)
  • Node: v14.16.0
  • npm: 7.7.0
@Lehks Lehks added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Mar 24, 2021
@darcyclarke darcyclarke added Priority 0 will get attention right away and removed Needs Triage needs review for next steps labels Mar 24, 2021
@wraithgar
Copy link
Member

wraithgar commented Mar 24, 2021

With no config this is not reproduceable. Can you share your npm config by typing npm config list?

There may be a bug with how save-prefix and/or save-exact are interacting, but will need to see your config to be sure.

Also please be sure you are using the latest npm (there have been a few bug releases since 7.7.0)

@Lehks
Copy link
Author

Lehks commented Mar 25, 2021

The output of npm config list is the following:

; "user" config from /home/lehks/.npmrc

//172.16.102.123:8182/repository/npm-private/:_authToken = "NpmToken.<token>"
//172.16.102.123:8182/repository/npm/:_authToken = "NpmToken.<token>"
registry = "http://172.16.102.123:8182/repository/npm/"

; node bin location = /usr/bin/node
; cwd = /home/lehks/repos/hello-nodejs
; HOME = /home/lehks
; Run `npm config ls -l` to show all defaults.

Also I've just tested again with npm 7.7.4 and the problem still exists.

@wraithgar
Copy link
Member

I still can't reproduce this w/ the info given. Can you try making a net new project (i.e. npm init -y) and see if installing it there has the same issue?

Are you installing by running npm install itself or are there other flags? Are there any environment variables you have set (i.e. from npm_config_*)

@wraithgar wraithgar added Needs Review Priority 2 secondary priority issue and removed Priority 0 will get attention right away labels Mar 25, 2021
@Lehks
Copy link
Author

Lehks commented Mar 26, 2021

I have tried setting up a new project and the problems still persist. The commands I executed were:

npm init -y
npm install my-package
npm install express

As before, my-package is from my private registry (express is the regular Express package - I also installed this to test a package from the public Package Registry). my-package is still beeing installed with version * and express is beeing installed properly.

There are no other environment variables that affect npm.

@Lehks
Copy link
Author

Lehks commented Mar 26, 2021

I have also tried doing the same thing on my regular Windows (not inside WSL) and the problem is the same there.

@wraithgar
Copy link
Member

How is npm being told to pull your package from your registry instead of the npm registry?

@Lehks
Copy link
Author

Lehks commented Mar 26, 2021

The output of npm config list is the following:

; "user" config from /home/lehks/.npmrc

//172.16.102.123:8182/repository/npm-private/:_authToken = "NpmToken.<token>"
//172.16.102.123:8182/repository/npm/:_authToken = "NpmToken.<token>"
registry = "http://172.16.102.123:8182/repository/npm/"

; node bin location = /usr/bin/node
; cwd = /home/lehks/repos/hello-nodejs
; HOME = /home/lehks
; Run `npm config ls -l` to show all defaults.

Also I've just tested again with npm 7.7.4 and the problem still exists.

It is being told through the config parameter

registry = "http://172.16.102.123:8182/repository/npm/"

in the quoted comment.

@wraithgar
Copy link
Member

May be related to #2844

@wraithgar wraithgar added Priority 1 high priority issue and removed Needs Review Priority 2 secondary priority issue labels Mar 26, 2021
@darcyclarke darcyclarke added this to the OSS - Sprint 28 milestone Apr 14, 2021
@domiSchenk
Copy link

@wraithgar this also happens if the last or only version is a beta.RC candidate
like with the current Tauri beta release:
npm install @tauri-apps/api

image

@wraithgar
Copy link
Member

@domiSchenk Thank you! That unlocked the solution for us, being able to reproduce it. The bug is actually in arborist.reify when it chooses to write the spec back to the package.json, was seeing if what ended up on disk intersected w/ the spec you asked for (which is * if none is given). But, because there was a semver-prefix range in play, that test was returning false.

We have a fix in flight now and this should be fixed soon and will go out hopefully w/ the next npm cli release.

@wraithgar wraithgar self-assigned this May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants