Global Install from git repository fails when using 'prepare' script and 'bin' path
Open
Nobody has claimed this yet.
Bug
Needs Triage
Release 7.x
- 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
Current Behavior
npm i -g github:<account>/<repository>.git
All files deleted from global install folder after prepare script runs
- Downloads package files and places them in the cache folder (expected):
.npm/_cacache/tmp/git-clone-xxxxxxxx - Copies files to global node_modules (expected):
.nvm/versions/node/v15.14.0/lib/node_modules/test-global-install - Creates link to specified bin file (expected):
.nvm/versions/node/v15.14.0/bin/my-test >> ../lib/node_modules/test-global-install/dist/test.js - All files in cache and install folder are deleted (unexpected):
.npm/_cacache/tmp/git-clone-xxxxxxxx/ (empty)
.nvm/versions/node/v15.14.0/lib/node_modules/test-global-install/ (empty)
Additional:
- The prepare script is executed twice (
~/prepare.txtwill have two entries). - The link remains, but points to nothing now that the files are deleted
- Local install works correctly
- Omitting the bin parameter from
package.json, this install works correctly - Omitting the prepare script from
package.json, this install works correctly - Works correctly with npm 6.x
Expected Behavior
npm i -g github:<account>/<repository>.git
Should result in:
- All (non-excluded) project files in the global node_modules folder
- Working link in the bin folder
Steps To Reproduce
Config:
Package.json
{
"name": "test-global-install",
"version": "1.0.0",
"description": "Minimal package to test ",
"main": "dist/test.js",
"author": "me",
"license": "ISC",
"dependencies": {},
"bin": {
"my-test": "dist/test.js"
},
"scripts": {
"prepare": "echo Prepare! >> ~/prepare.txt"
}
}
.gitignore:
node_modules/
.npmignore:
(empty)
dist/test.js
#!/usr/bin/env node
console.log("Hello There!");
Install from GitHub
`npm i -g github:<account>/<repository>.git`
Environment
- OS: Windows / Ubuntu 18.04
- Node: v15.14.0 / v16.6.0
- npm: 7.7.6 / v7.20.3
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
Reproduce the install using the shown package.json, .gitignore, .npmignore, dist/test.js, and npm i -g github:/.git command on the reported npm versions. Compare the cache and global node_modules contents, the bin link, and prepare.txt; done means project files remain installed, the link works, and prepare runs as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100