Skip to content
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

npm install 时 postinstall 脚本找不到的问题 #228

Open
wayou opened this issue Sep 10, 2020 · 0 comments
Open

npm install 时 postinstall 脚本找不到的问题 #228

wayou opened this issue Sep 10, 2020 · 0 comments

Comments

@wayou
Copy link
Owner

wayou commented Sep 10, 2020

npm install 时 postinstall 脚本找不到的问题

一些 npm 包在安装时会报如下 postinstall 脚本找不到的问题,比如 ``

$ npm i protobufjs

> protobufjs@6.10.1 postinstall /data/home/wayongliu/test_registry/node_modules/protobufjs
> node scripts/postinstall

sh: node: command not found
npm WARN test_registry@1.0.0 No description
npm WARN test_registry@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! protobufjs@6.10.1 postinstall: `node scripts/postinstall`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the protobufjs@6.10.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-09-10T02_51_28_993Z-debug.log

该错误同样会出现在对该包有依赖的情况下,即,不直接安装该包,只要依赖链条中包含该包,就会出现上述错误。

解决办法有两种,

—ignore-scripts

安装时指定 —ignore-scripts 参数可使得 npm 在完成安装后忽略 scripts 的执行,从而规避的该问题。

$ npm i —ignore-scripts

—unsafe-perm

安装时指定 —unsafe-perm 参数,同样可以规避掉上述报错。

$ npm i —unsafe-perm

相关资源

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant