[BUG] `--force` doesn't work as intended when automatically removing `node_modules` symlinks
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
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
If I have a symlink called node_modules to a different directory, then npm will remove this symlink and create a real folder. This has been introduced in https://github.com/npm/arborist/commit/f2b0ceebfe94123f162c3652af46f9c4c473cc36 as a safety feature, but as it doesn't disable it as specified when using --force option.
Other people have similar problems too:
Expected Behavior
It should work as intended in https://github.com/npm/arborist/commit/f2b0ceebfe94123f162c3652af46f9c4c473cc36 (don't remove symlink if --force).
I really needed this thing to work, so I had to downgrade npm to an older version.
Steps To Reproduce
- Create an empty folder
- Create a second folder inside the first one
- Run
npm init -y - Run
ln -s your_folder_name node_modules - Run
npm install --force <any package name> node_modulesno longer points toyour_folder_name
Environment
- npm: v8.3.1
- Node.js: v17.4.0
- OS Name: MacOS Catalina
- System Model Name: iMac
- npm config:
; this only showed comments and registry auth token "(protected)"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the behavior with the listed npm install --force steps, then inspect the symlink safety change in the linked npm/arborist commit. Trace the removal decision for node_modules and compare the --force option handling. Done means the node_modules symlink remains intact during the reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100