Repository navigation
[BUG] Installing a package globally from a git repo does not make any dependencies available during prepare script #8440
Description
Is there an existing issue for this?
- I have searched the existing issues
This issue touched on multiple things, and ended up closed: #1865
But, it seems evident that this particular problem was never resolved.
This issue exists in the latest npm version
- I am using the latest npm
Current Behavior
The docs state this about the "prepare" script:
NOTE: If a package being installed through git contains a prepare script, its dependencies and devDependencies will be installed, and the prepare script will be run, before the package is packaged and installed.
This is evidently not true:
% npm install --include=dev -g "https://github.com/backtrace-labs/backtrace-morgue.git#cstrahan/test" --foreground-scripts
up to date in 232ms
npm error code 127
npm error git dep preparation failed
npm error command /Users/charles.strahan/.local/share/mise/installs/node/24.4.0/bin/node /Users/charles.strahan/.local/share/mise/installs/node/24.4.0/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/charles.strahan/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm error > backtrace-morgue@1.24.11 prepare
npm error > npm run build
npm error
npm error
npm error > backtrace-morgue@1.24.11 build
npm error > npm run clean && npm run compile
npm error
npm error
npm error > backtrace-morgue@1.24.11 clean
npm error > tsc -b --clean
npm error npm warn using --force Recommended protections disabled.
npm error npm warn using --force Recommended protections disabled.
npm error npm warn using --force Recommended protections disabled.
npm error sh: tsc: command not found
npm error npm error code 127
npm error npm error path /Users/charles.strahan/.npm/_cacache/tmp/git-clonePcQvUY
npm error npm error command failed
npm error npm error command sh -c npm run build
npm error npm error A complete log of this run can be found in: /Users/charles.strahan/.npm/_logs/2025-07-17T22_30_03_974Z-debug-0.log
npm error A complete log of this run can be found in: /Users/charles.strahan/.npm/_logs/2025-07-17T22_29_57_297Z-debug-0.log
Note the sh: tsc: command not found.
I have a project written in typescript, and I need to run the compiler in the prepare script in order to have the *.js source generated, otherwise installing from git (e.g. npm install -g "https://github.com/backtrace-labs/backtrace-morgue.git#cstrahan/test) will result in a broken package being installed.
I have tried with several versions of node (including node installed through brew) and their bundled npm, including the latest of each, and I have not seen the desired, advertised behavior.
% npm --version
11.4.2
% node --version
v24.4.0
Expected Behavior
As stated in the docs, the packages listed in "dependencies" and "devDependencies" should be available in the installation environment during the prepare script.
Steps To Reproduce
- In this environment...
- With this config...
- Run '...'
- See error...
Environment
- npm: 11.4.2
- Node.js: v24.4.0
- OS Name: macOS
- System Model Name:
- npm config:
; "builtin" config from /opt/homebrew/lib/node_modules/npm/npmrc
prefix = "/opt/homebrew"
; node bin location = /opt/homebrew/Cellar/node/24.3.0/bin/node
; node version = v24.3.0
; npm local prefix = /Users/charles.strahan
; npm version = 11.4.2
; cwd = /Users/charles.strahan
; HOME = /Users/charles.strahan
; Run `npm config ls -l` to show all defaults.
Activity
cstrahan commentedon Jul 17, 2025
Okay, installing without
-gworks as expected:but it doesn't work with
-g:and here's the log file:
cstrahan commentedon Jul 17, 2025
For comparison, here are the logs from when I didn't pass
-g:fix: track dist/ in git for npm install from GitHub
docs: update install instructions with working one-liner
docs: make pnpm the recommended install method
fix(margins-cli): commit dist/ for working global install from GitHub
Ship prebuilt dist/ and stop building during install
docs: install via GitHub tarball URL, not github: shorthand
fix: Use a different installation approach
fix: Use a different installation approach
fix: Use a different installation approach
fix: Use a different installation approach
fix: Use a different installation approach
MacOS commentedon Jul 24, 2026
This
BUGis persisting, am I correct? I ask because I have the same issue.Make npm install -g github:... work end to end
README:从源码装的写法改成两步 —— 一行 git 装踩在 npm 未修的 bug 上
Install ade from a package file built with npm pack