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 >= 9.4.2 install-links=true doesn't behave the same as in npm 9.4.1 #6302

Closed
2 tasks done
spongenee opened this issue Mar 29, 2023 · 4 comments
Closed
2 tasks done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release

Comments

@spongenee
Copy link

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

Environment: darwin, node 19.8.1, framework 3.22.0 (local), plugin 6.2.3, SDK 4.3.2

Our package.json file worked with npm 9 versions prior to 9.4.2, and broke in later versions. I read the change log and think that the install-links change to false in 9.4.2 is most relevant: #6142

Let me explain more on how we manage packages and the errors we see in the version change from npm 9.4.1 to 9.4.2. We developed npm local packages and the package.json points to file:../package and the package version is defined in ../package/package.json, say 1.0.0.

npm i in 9.4.1 will install all the dependencies of the local package, npm ls -prod -json -depth=1 has no error and outputs the following

    "package": {
      "version": "1.0.0",
      "resolved": "file:/path/to/package",
      "overridden": false,
      "dependencies": {
        "another_local_package": {
          "version": "1.0.0"
        },
        "decimal.js": {
          "version": "7.5.1",
          "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-7.5.1.tgz",
          "overridden": false
        }
      }
    }

in npm 9.4.2 and the latest 9.6.2, we see the following after npm i

    "package": {
      "version": "1.0.0",
      "resolved": "file:/path/to/package",
      "overridden": false,
      "dependencies": {
        "decimal.js": {
          "missing": true,
          "problems": [
            "missing: decimal.js@^7.5.1, required by package@1.0.0"
          ]
        }
    }

As I understand the install-links flag was default to true prior to 9.4.2 so I tried npm i --install-links in npm 9.4.2 and we see a different error. the same for npm 9.6.2

    "package": {
      "version": "1.0.0",
      "resolved": "file:/path/to/package",
      "overridden": false,
      "invalid": "\"file:../package\" from the root project",
      "problems": [
        "invalid: package@1.0.0 /path/to/package"
      ],
      "dependencies": {
        "decimal.js": {
          "version": "7.5.1"
        }
     }

If I change package.json to "package": "1.0.0" instead of "package": "../package", then another npm i will resolve the error. But that is very not ideal as that will not work without the prior install, it will try to look for the local package in public npm repos and get 404 error.

What can I do to make npm i behave as in 9.4.1 in later versions?

Expected Behavior

No errors in later versions with install-links=true flag

Steps To Reproduce

npm i
npm ci
npm ls -prod -json -depth=1

Only happens for npm versions >= 9.4.2
No error for prior npm 9 versions

Environment

  • npm: same behaviour on npm 9.4.2, 9.5.1, 9.6.2
  • Node.js: 19.8.1
  • OS Name: MacOS Ventura 13.2.1
  • System Model Name: Macboook Pro
  • npm config:
❯ npm config ls
; node bin location = /Users/user/.nvm/versions/node/v19.8.1/bin/node
; node version = v19.8.1
; npm local prefix = /Users/user/Dev/atvenu/stripe-pos-api
; npm version = 9.6.2
; cwd = /Users/user/Dev/atvenu/stripe-pos-api
; HOME = /Users/user
@spongenee spongenee added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Mar 29, 2023
@wraithgar
Copy link
Member

What can I do to make npm i behave as in 9.4.1 in later versions?

Add install-links=true to the .npmrc file in your project.

@spongenee
Copy link
Author

What can I do to make npm i behave as in 9.4.1 in later versions?

Add install-links=true to the .npmrc file in your project.

@wraithgar wow that fixed the issue! Thank you!! is there a reason why it behaves differently from running npm i --install-links=true?

@wraithgar
Copy link
Member

It shouldn't, and the example you gave didn't indicate you were using that flag

@spongenee
Copy link
Author

I tried using the flag --install-links=true and --install-links. Dependencies in local packages were installed but both show invalid package errors, and without the flag it is missing package error.

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 9.x work is associated with a specific npm 9 release
Projects
None yet
Development

No branches or pull requests

2 participants