[BUG] npm build is either false documented or not executed (on git dependencies)
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
Scripts will not be run when installing git dependencies (wrong docs? or feature disappeared?)
Docs (https://docs.npmjs.com/cli/v8/configuring-npm/package-json#git-urls-as-dependencies) claim that:
When installing from a git repository, the presence of certain fields in the package.json will cause npm to believe it needs to perform a build. To do so your repository will be cloned into a temporary directory, all of its deps installed, relevant scripts run, and the resulting directory packed and installed.
This flow will occur if your git dependency uses workspaces, or if any of the following scripts are present:
build
prepare
prepack
preinstall
install
postinstall
If your git repository includes pre-built artifacts, you will likely want to make sure that none of the above scripts are defined, or your dependency will be rebuilt for every installation.
Expected Behavior
implement, what you wrote in the docs, or adjust the docs accordingly.
Steps To Reproduce
I have prepared a very simple demo that can be used for testing:
https://github.com/hsjobeki/will-not-be-built
install with npm install hsjobeki/will-not-be-built
expected:
"scripts": {
"build": "echo \"Build step executed\" > ./test"
},
so there should be a file called test in the folder. after installation (node_modules/will-not-build/test)
Or do i miss something?
Environment
- npm: 8.9.0
- Node.js: v18.2.0
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 report with npm install hsjobeki/will-not-be-built using npm 8.9.0 and Node.js v18.2.0, then compare the result with the npm package.json documentation for Git URLs as dependencies. Done means either the documented scripts run and produce node_modules/will-not-build/test, or the documentation accurately describes the observed behavior.
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
- Mostly clear
- Newbie friendliness
- 42/100