-
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] npm ci
doesn't run postinstall
script
#1905
Comments
I think this is functioning as intended or at least the same as npm The If you want to execute some code every time you run Definitely let me know if I'm wrong though & that this is/was working on a previous version of the CLI. Other option here is just to chain (ie. |
Hmm, looking into this a bit more, I know that we did want to quiet down installs & we did implement an RFC for that (ref. https://github.com/npm/rfcs/blob/latest/implemented/0022-quieter-install-scripts.md); But we should still be running those. I'll file this & see if we can get someone to dig in a bit more. |
I can second this. I have projects using Husky. When doing a fresh install, Husky does not run, nor does it install the git hooks. This was changed from NPM v6 to NPM v7. One thing that's slightly different than OP's issue, is that (I believe) the postinstall scripts run are in Husky's module, and not in the root project's scripts. Example
|
I'm using
https://github.com/mobilusoss/textlint-browser-runner/blob/master/package.json#L18
But npm v7.0.3 does not call My solution is calling |
Confirm. Breaking change since npm 7.0.0 Probably caused by
|
Will this be considered as a bug or as a breaking change for npm 7? |
@darcyclarke @isaacs apologies for the direct tags, but I see that this issue was removed from one of the sprint milestones, so I want to make sure that it wasn't overlooked as it's a fairly major regression. Here's a minimal repro, in case it's not clear from the original issue: {
"scripts": {
"prepare": "echo foo"
}
} With The problem is that the install command has the following block to explicitly run the appropriate install scripts, but the ci command has no such block: Lines 44 to 62 in a28aff7
|
Runs the prepare script manually, since npm@7 has a bug and no longer runs the prepare script when running `npm ci`. See: npm/cli#1905
fwiw, this breaks builds that use patch-package |
This should be considered as a bug and should be higher priority IMHO. So many packages out there use |
Yes, this is a bug. We misunderstood the initial report to be about deps being installed, not the install/etc scripts of the root project, sorry about that. Will be fixed on the next release. |
`npm ci` should run all the same preinstall/install/postinstall/prepare scripts for the root project just like `npm install`. Fixes: #1905
Despite npm/cli#1905 being fixed for `[email protected]`, there are still issues with installing `puppeteer` using `npm@7`. See puppeteer/puppeteer#6586 (comment) Therefore, we're reverting the accidental schema upgrade from 0d1e40b to the previous version, and removing `markdownlint-cli` once more.
Running with node v14 or v15 and npm v7, I'm finding that the "install" script of the modules being installed don't run if "npm install" is run in the directory of the dependent module. Is that related to this problem or should I file a new bug? Very simple to reproduce:
The message "FOOBAR!!!" never appears with npm v7, whereas it does with npm v6 and node v14. This is a huge problem. |
What's the workaround for modules that were doing interactive install? With output and input from the user? This "quieting" has broken things badly for me! Apparently, if the module calls readline() it just never executes at all. |
For anyone else getting here after searching on Someone could probably write a script to update |
Curious why the determination as to whether or not a package has a |
Performance I assume. |
@CalculonPrime https://docs.npmjs.com/cli/v7/using-npm/config#foreground-scripts |
Published a package on npm to do this. This will minimize change for anyone in tightly managed environments. Run this is the same directory as
|
still in [email protected] example vue-demi npm install not running dependencies's postinstall |
[email protected] does work IF it is converting the version of the |
Ok .thanks. I will try it later. |
While this does cause the prompt for my npm module to show up, my module not only has a prompt. It also shows an interactive download status during installation using cursor movement commands. Both the query string and periodic download progress output are now injected with spam from some other dependency (bluebird npm module?) like: [##################] \ reify:bluebird: timing reifyNode:node_modules/binary Completed in 331ms which gets injected after every printed string and overwritten on top of my refreshing status line. I tried to suppress foreground-scripts for my own module's dependencies with an .npmrc file declaration, but even after forcing that file to be added to npm pack, it has no effect, I suspect because my dependencies are added as siblings of my module by npm, rather than in my module's own node_modules directory. So, unfortnately, your suggestion isn't a working replacement for npm v6 behavior (which didn't inject spam output like that). [Update: this problem has nothing to do with bluebird npm package or its parent unzipper, which is how my module has a dependency on it. If I remove unzipper, then I see similar spam from a different dependency. So something in npm v7 is echoing some log message (the last one?) from a dependency and spamming the install/postinstall process with it so that any module actually outputting via "--foreground-scripts" generates garbled output. If I apply "--quiet" there is no impact. If I apply "--silent" then the problem is solved, but only because that seems to switch off "--foreground-scripts".] |
I think we were reliant on buggy behaviour in npm@7 where `npm ci` wasn't running some of the lifecycle hooks: npm/cli#1905 (comment) This got fixed in npm@8 but now our CI process breaks: npm/cli@d825e90 Decided to follow the recommendations from husky's docs to do this so it doesnt run the `prepare` step: ```sh npm ci --ignore-scripts ``` https://github.com/typicode/husky/blob/0bcdac6b4dad6eedecc49cf3837ecc05b321db2e/docs/README.md#disable-husky-in-cidockerprod=
* feat: adding support for node 18, dropping node 12 * chore: bump the root lockfile * ci: installing the latest npm 8 in most environmnets * ci: install npm8 everywhere in ci * ci: debugging * fix: add --ignore-scripts to `npm ci` in github action I think we were reliant on buggy behaviour in npm@7 where `npm ci` wasn't running some of the lifecycle hooks: npm/cli#1905 (comment) This got fixed in npm@8 but now our CI process breaks: npm/cli@d825e90 Decided to follow the recommendations from husky's docs to do this so it doesnt run the `prepare` step: ```sh npm ci --ignore-scripts ``` https://github.com/typicode/husky/blob/0bcdac6b4dad6eedecc49cf3837ecc05b321db2e/docs/README.md#disable-husky-in-cidockerprod= Co-authored-by: Dom Harrington <[email protected]>
* feat: adding support for node 18, dropping node 12 * chore: bump the root lockfile * ci: installing the latest npm 8 in most environmnets * ci: install npm8 everywhere in ci * ci: debugging * fix: add --ignore-scripts to `npm ci` in github action I think we were reliant on buggy behaviour in npm@7 where `npm ci` wasn't running some of the lifecycle hooks: npm/cli#1905 (comment) This got fixed in npm@8 but now our CI process breaks: npm/cli@d825e90 Decided to follow the recommendations from husky's docs to do this so it doesnt run the `prepare` step: ```sh npm ci --ignore-scripts ``` https://github.com/typicode/husky/blob/0bcdac6b4dad6eedecc49cf3837ecc05b321db2e/docs/README.md#disable-husky-in-cidockerprod= Co-authored-by: Dom Harrington <[email protected]>
still not work at [email protected] |
Current Behavior:
npm ci
doesn't run thepostinstall
scriptExpected Behavior:
npm ci
should run thepostinstall
scriptSteps To Reproduce:
npm install
npm ci
npm ci
DOES NOT run thepostinstall
scriptEnvironment:
ex.
The text was updated successfully, but these errors were encountered: