[BUG] npm link removes previously linked module
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
What / Why
Developing coupled packages linked with npm link is not optimal.
npm linkbreaks the linked package.npm linkremoves others links. (regression from npm 6)
When
Developing/testing linked packages together
Where
- n/a
How
Current Behavior
- n/a
Steps to Reproduce
Preparing the environment
git clone https://github.com/yeoman/environment.git
cd environment
npm ci
npm link
cd ..
git clone https://github.com/yeoman/generator.git
cd generator
npm ci
npm link
cd ..
git clone https://github.com/yeoman/yeoman-test.git
cd yeoman-test
npm ci
npm link
cd ..
Reset the environment
cd environment
npm ci
cd ..
cd generator
npm ci
cd ..
cd yeoman-test
npm ci
cd ..
npm linkbreaks the linked package.
cd yeoman-test
npm link yeoman-generator
npm test
output:
Error: Cannot find module 'semver'
Require stack:
- /Users/mshima/git/reproduce/generator/lib/index.js
- /Users/mshima/git/reproduce/yeoman-test/test/helpers.js
Workaround go to generator folder and execute npm ci
npm linkremoves others links. (regression from npm 6)
cd yeoman-test
npm link yeoman-generator
ls -l node_modules/yeoman-*
output:
lrwxr-xr-x 1 mshima staff 15 6 Mar 12:14 node_modules/yeoman-generator -> ../../generator
node_modules/yeoman-environment:
total 24
drwxr-xr-x 4 mshima staff 128 6 Mar 12:14 cli
.
.
.
npm link yeoman-environment
ls -l node_modules/yeoman-*
output:
lrwxr-xr-x 1 mshima staff 17 6 Mar 12:20 node_modules/yeoman-environment -> ../../environment
node_modules/yeoman-generator:
total 32
-rw-r--r-- 1 mshima staff 1292 26 Out 1985 LICENSE
drwxr-xr-x 5 mshima staff 160 6 Mar 12:20 lib
.
.
.
Workaround: link both together npm link yeoman-generator yeoman-environment
ls -l node_modules/yeoman-*
lrwxr-xr-x 1 mshima staff 17 6 Mar 12:20 node_modules/yeoman-environment -> ../../environment
lrwxr-xr-x 1 mshima staff 15 6 Mar 12:22 node_modules/yeoman-generator -> ../../generator
Expected Behavior
- should not break node_modules tree.
- should not remove others manually linked modules.
Who
- n/a
References
- n/a
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 two failures with the provided environment, generator, and yeoman-test clone commands, then run npm link yeoman-generator and npm link yeoman-environment followed by npm test. Compare the linked and unlinked node_modules/yeoman-* entries. Done means linked packages retain their dependencies and linking one package does not remove another manual link.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100