-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] prepare
and prepack
scripts are not handled as documented when installing a git dependency
#1865
Comments
@kimamula just to confirm, does this behavior reflect how |
@darcyclarke The behavior of
|
I seem to be hitting a similar case but where the With NPM 6, the following worked: npm install --save-dev git+https://github.com/codemirror/google-modes.git#57b26bb0e76ca5d3b83b12faf13ce1054d34bdd But with NPM 7 it fails, seemingly because the npm install --save-dev git+https://github.com/codemirror/google-modes.git#57b26bb0e76ca5d3b83b12faf13ce1054d34bdd
npm ERR! code 127
npm ERR! git dep preparation failed
npm ERR! command /home/aomarks/node/bin/node /home/aomarks/node/lib/node_modules/npm/bin/npm-cli.js install --only=dev --prod --ignore-prepublish --no-progress --no-save --cache=/home/aomarks/.npm/_cacache --prefer-offline=false --prefer-online=false --offline=false --before=
npm ERR! > [email protected] prepare
npm ERR! > npm run build && npm test
npm ERR!
npm ERR!
npm ERR! > [email protected] build
npm ERR! > npm run build-js && npm run build-ts && npm run build-c && npm run build-cpp && npm run build-clif && npm run build-fbs && npm run build-py && npm run build-go && npm run build-java && npm run build-html && npm run build-ng && npm run build-kotlin
npm ERR!
npm ERR!
npm ERR! > [email protected] build-js
npm ERR! > grammar-mode --es-module src/javascript.grammar --output src/javascript.mode.js && rollup -c rollup.config.js src/javascript.js -o dist/javascript.js
npm ERR! npm WARN invalid config before="" set in command line options
npm ERR! npm WARN invalid config Must be one of: null, valid Date string
npm ERR! sh: 1: grammar-mode: not found
npm ERR! npm ERR! code 127
npm ERR! npm ERR! path /home/aomarks/.npm/_cacache/tmp/git-clone-ae2eb4f5
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c grammar-mode --es-module src/javascript.grammar --output src/javascript.mode.js && rollup -c rollup.config.js src/javascript.js -o dist/javascript.js
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR! /home/aomarks/.npm/_cacache/_logs/2020-10-21T22_12_07_990Z-debug.log
npm ERR! npm ERR! code 127
npm ERR! npm ERR! path /home/aomarks/.npm/_cacache/tmp/git-clone-ae2eb4f5
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c npm run build-js && npm run build-ts && npm run build-c && npm run build-cpp && npm run build-clif && npm run build-fbs && npm run build-py && npm run build-go && npm run build-java && npm run build-html && npm run build-ng && npm run build-kotlin
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR! /home/aomarks/.npm/_cacache/_logs/2020-10-21T22_12_08_013Z-debug.log
npm ERR! npm ERR! code 127
npm ERR! npm ERR! path /home/aomarks/.npm/_cacache/tmp/git-clone-ae2eb4f5
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c npm run build && npm test
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR! /home/aomarks/.npm/_cacache/_logs/2020-10-21T22_12_08_023Z-debug.log
npm ERR! A complete log of this run can be found in:
npm ERR! /home/aomarks/.npm/_logs/2020-10-21T22_12_08_070Z-debug.log |
This bug causes problems for https://travis-ci.org/github/zloirock/core-js/builds/738834230 |
This is a bug in pacote. npm/pacote#53 |
Will be fixed in the next cli release (ie, tomorrow, likely included with the Node.js 15 release going out next week). |
Yeah, those look like duplicates. |
Can anyone double-check that this problem has actually been fixed? npm i fregante/select-dom#edd18f4 --verbose # with prepack
npm i fregante/select-dom#32f1864 --verbose # with prepare Testing on Node v15.2.1, macOS 10.15.7. I tried with npm 6 and |
I can confirm it works for me now, at least for my particular case outlined here: #1865 (comment) |
Still no luck for me on npm 7.6.0. This still results in an semi-empty package folder
|
why is this issue closed? the problem has not been solved in 7.19.1 |
During npm install, the Lighthouse package which is installed from GitHub (@master branch) triggers the newly added `prepack` script [1], but due to a bug in NPM [2] the devDependencies are not available when the script is run, thus making the installation fail. [1]: GoogleChrome/lighthouse#13261 [2]: npm/cli#1865
During npm install, the Lighthouse package which is installed from GitHub (@master branch) triggers the newly added `prepack` script [1], but due to a bug in NPM [2] the devDependencies are not available when the script is run, thus making the installation fail. [1]: GoogleChrome/lighthouse#13261 [2]: npm/cli#1865
There were two problems documented in this issue.
The first has been fixed, the second has not. Repro Example I have a test package called npm-lib with the following package.json {
"scripts": {
"prepack": "ls | cowsay > prepacked.txt",
"prepare": "ls | cowsay > prepared.txt"
},
"devDependencies": {
"cowsay": "^1.5.0"
}
} I add this to another package like so with the commit hash: "dependencies": {
"npm-lib": "github:jameskerr/npm-lib#7cb685db9a232c44057b2be3a97cff183972b4cd"
}, I then run npm version 6.14.15
npm version 7.24.2
The contents of the prepared.txt show that the dev dependency (cowsay) was installed:
Should I open a new issue? |
I can confirm that the issue that {
"scripts": {
"prepare": "tsc ..."
},
"devDependencies": {
"typescript": "..."
}
} Running
whereas yarn handles this installation perfectly well. As a temporary workaround the required |
This still seems to cause trouble though, see npm/cli#1865
I can confirm that on npm version 9.4.1, |
workspaces/libnpmpack/lib/index.js is the only place in this codebase which calls |
Why would prepack run with git deps, when they’re never packed or published? |
That makes sense, but the lifecycle of npm scripts still seems alien to me. I recall Installing from |
Prepack works great for a “before publish” step; i use it - but git deps are never published. prepare is used when you want to support installing from git (which i have no interest in), and it should run pre publish and pre install. |
Exactly, but why do you use it? Is it to run a build? Then it'd make sense to have a script that runs when installing from
Do you say that as a module author? Then yeah, that's not great, is it. As a module author myself, I shouldn't need to bother about that either. Does |
I use it to autogenerate an npmignore file, which isn’t a relevant task unless it’s being published. As a module author, i always need to bother with the way my users install things - anything i support is something i have to support, and since i believe nothing should ever be consumed except from an npm registry, that’s what i wish to support. npm install supports that, but the thing you’re installing may not. |
From the docs, |
Not to pile on here, but, we were actually considering adding a
Does this need to be filed as a brand new issue? Reopened? Is npm/pacote#257 the right place for this now? |
is this happening again ? |
@aovchinn Not sure your linked issue is relavent to this issue; this issue is about Er, no, sorry. This issue contains multiple issues all in one. |
Current Behavior:
I tested installing a git dependency which has either
prepare
orprepack
script with npm CLI v7.0.0-beta.12 and confirmed the following behaviors.prepare
script:devDependencies
are NOT installed but theprepare
script is executedprepack
script:devDependencies
are NOT installed and theprepack
script is NOT executedExpected Behavior:
prepare
script:devDependencies
are installed and theprepare
script is executedprepack
script:devDependencies
are installed and theprepack
script is executeddevDependencies
are installed when installing a git dependency with aprepack
script and actually they are not installed even when npm CLI v6 is used, I believe npm should install them since running aprepack
script without installingdevDependencies
does not make sense.Steps To Reproduce:
prepare
:prepack
:$ npm install github:kimamula/prepack-test changed 1 package, and audited 1 package in 6s found 0 vulnerabilities
->
tsc
should generateindex.js
file, but it's not generated.Environment:
The text was updated successfully, but these errors were encountered: