-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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] lifecycle hooks do not work with unsafe-perm=false
#1004
Comments
Hi, @CarstenLeue , I am also facing the similar issue with postinstall lifecycle hook, where I run npm install with unsafe-perm the postinstall lifecycle hook script is being executed but without unsafe-perm it does not execute with warn postinstall: cannot run in wd Did you get any solution for the same ? Thanks, |
This issue is the same than npm-lifecycle#49. From my analysis it is mandatory to set |
npm If your bug is preproducible on If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo Closing: This is an automated message. |
I reproduced this with npm 6, but not with npm 7 and npm 8 so the bug seems fixed in npm 7+! Thanks! |
What / Why
I have a lifecylehook for
postversion
. This hook is not being called if I run withunsafe-perm=false
instead the command warns with:After debugging the NPM code I found that this line caused the issue:
The failing check is:
In the case of the version script
opts.dir
points to thenode_modules
subdirectory ofwd
, so the check always returnstrue
.in my test
wd
is/usr/build/carsten-new-project
butopts.dir
is/usr/build/carsten-new-project/node_modules
.This looks like a general issue in how the
opts.dir
is initialized since I cannot control it calling the version command.When
When executing the version command as part of a
postversion
script.Where
You can use the trivial example at
https://github.com/Carsten-Leue/npm-unsafe-perm
to reproduce. Make sure to run withunsafe-perm=false
The text was updated successfully, but these errors were encountered: