[BUG] npm install removes linked packages, npm link replaces linked package contents
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
I have specified a package in my package.json that I have also linked with a local version I use for development. When I run npm i in the parent package, the symlink is removed, the package is installed from npm, and I use the live version instead, not my local development one.
Later, if I run npm link, the package correctly get linked with my local version, but everything is replaced with the downloaded version, meaning that all my local development files are replaced with the contents of the tarball downloaded from npm. This means I have to go in my package folder, clone the repo again, checkout the files from the master branch... Not to mention that if I have any unsaved work, it would get completely erased with no chance to get it back even via Git - because the .git folder is also deleted.
Current Behavior:
- running
npm iremoves linked packages and installs their published versions instead - running
npm link <package>replaces the contents of the symlinked package folder with the published package's tarball contents
Expected Behavior:
- running
npm ishould ignore packages innode_modulesthat are symlinked - running
npm link <package>should only create a symlink and leave everything in the symlinked folder intact
Steps To Reproduce:
- Install a package from npm in a project
- Run
npm linkin a different, local version of the package - Run
npm link <package>in the project - Run
npm i - Linked package is removed
- Run
npm link <package>in the project - Local version is replaced with the published tarball contents
Environment:
- OS: Microsoft Windows 10 Pro, 10.0.18363 Build 18363
- nvm: 1.1.7
- Node: 15.4.0
- npm: 7.0.15 (can't install 7.2 due to nvm)
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 listed npm link and npm i sequence on the stated Node 15.4.0/npm 7.0.15 environment. Trace the package-manager paths handling linked packages and compare the symlink and package contents before and after each command. Done means npm i preserves linked packages and npm link does not overwrite the local package or its .git directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100