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] --install-links=true installs/updates local paths differently from --install-links=false #7169

Closed
2 tasks done
DanKaplanSES opened this issue Jan 23, 2024 · 5 comments
Closed
2 tasks done
Labels
Bug thing that needs fixing Release 10.x

Comments

@DanKaplanSES
Copy link
Contributor

DanKaplanSES commented Jan 23, 2024

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

"Version 1" is printed.


  1. When you install local paths with --install-links=false (full behavior), modifications to that local path are reflected in the dependent app.
  2. When you install local paths with --install-links=true, modifications to that local path do not update the dependency unless the version number is incremented.

According to the local paths documentation:

This feature is helpful for local offline development and creating tests that require npm installing where you don't want to hit an external server, but should not be used when publishing packages to the public registry.

I believe 1. is desired and intended behavior because it makes offline testing more convenient. 2. came as a surprise to me and I can't find it documented anywhere. For this reason, I believe this difference in behavior is a bug.

Expected Behavior

"Version 2" is printed.

Steps To Reproduce

  1. Git clone https://github.com/DanKaplanSES/jsdom-sandbox/tree/update-install-links-reproducible
  2. cd update-install-links-reproducible
  3. ./setup.sh
  4. Modify lib-package/index.js in some way, e.g., make it log "Version 2"
  5. ./npm.sh install/update with or without --force, with or without lib-package, etc.
  6. ./npma.sh run exec

Environment

  • npm: 10.3.0
  • Node.js: 20.10.0
  • OS Name: Windows
  • System Model Name: 10
  • npm config:
; "builtin" config from C:\Users\myuser\AppData\Roaming\npm\node_modules\npm\npmrc

prefix = "C:\\Users\\myuser\\AppData\\Roaming\\npm"

; "user" config from C:\cygwin64\home\myuser\.npmrc

//registry.npmjs.org/:_authToken = (protected)
registry = "https://registry.npmjs.org/"
script-shell = "C:\\cygwin64\\bin\\bash.exe"

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v20.10.0
; npm local prefix = C:\my-projects\jsdom-sandbox
; npm version = 10.3.0
; cwd = C:\my-projects\jsdom-sandbox
; HOME = C:\cygwin64\home\myuser
; Run `npm config ls -l` to show all defaults.
@DanKaplanSES DanKaplanSES added Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x labels Jan 23, 2024
@DanKaplanSES DanKaplanSES changed the title [BUG] Installing local paths with --install-links=true installs/updates future releases differently from --install-links=false [BUG] --install-links=true installs/updates local paths differently from --install-links=false Jan 23, 2024
@kchindam-infy kchindam-infy added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Dec 10, 2024
@kchindam-infy
Copy link

--install-link=true should be used when you want to treat the local folder as package instead of symlink
The same is documented in https://docs.npmjs.com/cli/v8/commands/npm-install

@DanKaplanSES
Copy link
Contributor Author

--install-link=true should be used when you want to treat the local folder as package instead of symlink The same is documented in https://docs.npmjs.com/cli/v8/commands/npm-install

Can you expand on that? I'm not sure what action you're recommending. Thanks

@kchindam-infy
Copy link

  1. When you install local paths with --install-links=false (full behavior), modifications to that local path are reflected in the dependent app.

--install-links=false in the this case npm treats the local paths as symlinks and any changes to the local path are immediately reflected in to the dependent app, which helps in development

  1. When you install local paths with --install-links=true, modifications to that local path do not update the dependency unless the version number is incremented.

--install-links=true should be user If you want to install the content of a directory like a package from the registry instead of creating a link. I this case the local path is treated as a package from registry and hence it doesn't update upon changing local paths. In case of re-install, npm compares the version before updating it, so this gets updated only when the version number is incremented .

This is documented in https://docs.npmjs.com/cli/v8/commands/npm-install as below lines

NOTE: If you want to install the content of a directory like a package from the registry instead of creating a link, you would need to use the --install-links option.

#7171 is an example issue which show the need for --install-links=true

@kchindam-infy
Copy link

Closng the issue due to inactivity. Feel free to open the iissue if you need more iinformation

@DanKaplanSES
Copy link
Contributor Author

@kchindam-infy Thanks for the explanation.

I'm confused about this part:

--install-links=false [the default] ... any changes to the local path are immediately reflected in to the dependent app ...

If this is the case, shouldn't "Version 2" have been printed? I changed lib-package/index.js (step 4.), and my change was not immediately reflected in the dependent app (app-package): It prints "Version 1" instead of my change to print "Version 2".

@kchindam-infy kchindam-infy removed the Priority 2 secondary priority issue label Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Release 10.x
Projects
None yet
Development

No branches or pull requests

2 participants