You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
install and postinstall are npm scripts that run while npm install ${package} or npm ci.
It means that we allow the package author to run any scripts on our machine, which is definitely dangerous if we don't recognize what packages are installed as dependencies.
Unfortunately, it might be impossible to recognize all the dependencies on your project so we run scripts we don't know while npm install.
To avoid this, we can use the --ignore-scripts option, which disables all npm scripts while installing dependencies.
But sometimes the scripts are required to work the packages.
But I think it would be nice if npm has the mechanism to opt-in install and postinstall scripts.
I guess there are some ways to do this. The followings are ideas on me. Please let me know If you have any ideas 🙏
whitelistScripts in package.json
This field is to allow packages to run npm scripts.
With this option, we can share the information that we allow packages to run scripts through the package.json.
It might be better this option is enabled only with --whitelist-scripts option.
This option is to show a prompt whether you run the script or not.
This is useful if you know what the script would do.
Do you run the install script for fsevents?
y/n
other option
This is another feature request for --ignore-scripts.
I hope that npm prints all scripts not to run while installing with --ignore-scripts like https://github.com/koba04/install-scripts.
When
npm install or npm ci
Where
npm public registry
How
Current Behavior
run all install and postinstall scripts or don't run any scripts with --ignore-scripts option.
What / Why
install
andpostinstall
are npm scripts that run whilenpm install ${package}
ornpm ci
.It means that we allow the package author to run any scripts on our machine, which is definitely dangerous if we don't recognize what packages are installed as dependencies.
Unfortunately, it might be impossible to recognize all the dependencies on your project so we run scripts we don't know while
npm install
.To avoid this, we can use the
--ignore-scripts
option, which disables all npm scripts while installing dependencies.But sometimes the scripts are required to work the packages.
I've created an npm package to print all these scripts in your project.
https://github.com/koba04/install-scripts
But I think it would be nice if npm has the mechanism to opt-in
install
andpostinstall
scripts.I guess there are some ways to do this. The followings are ideas on me. Please let me know If you have any ideas 🙏
whitelistScripts
inpackage.json
This field is to allow packages to run npm scripts.
With this option, we can share the information that we allow packages to run scripts through the package.json.
It might be better this option is enabled only with
--whitelist-scripts
option.--confirm-scripts
This option is to show a prompt whether you run the script or not.
This is useful if you know what the script would do.
other option
This is another feature request for
--ignore-scripts
.I hope that npm prints all scripts not to run while installing with
--ignore-scripts
like https://github.com/koba04/install-scripts.When
npm install
ornpm ci
Where
How
Current Behavior
install
andpostinstall
scripts or don't run any scripts with--ignore-scripts
option.Expected Behavior
Who
References
The text was updated successfully, but these errors were encountered: