我在我的安装后脚本中执行了 node-gyp rebuild
。如果在执行期间运行 node-gyp rebuild
,将会出现错误。如何在不执行 node-gyp rebuild
的情况下运行 npm install
?
你可以做:
npm install --ignore-scripts
但它并不完美,因为它防止执行所有依赖项的脚本。
如果您不想使用 npm install --ignore-scripts
安装,而是只想使用 npm install,您可以通过一些 noop 来覆盖 package.json 中的安装脚本。例如:
"scripts" : {
"install" : "echo"
}
非常好用(也已经测试过yarn)
在 package.json 文件的 scripts 部分添加以下内容:
"scripts": {
"install": "install -d $(pwd)"
}
-d
标志。你能详细说明一下这里发生了什么吗? - ccnokes