Node.js 如何添加自定义NPM后安装脚本?

Node.js 如何添加自定义NPM后安装脚本?,node.js,npm,Node.js,Npm,每当我运行npm安装时,它都会运行npm运行postinstall。如何添加自定义安装后脚本?因此,在运行npm install之后,它会运行npm run postinstall2?您可以通过将多个脚本与&&链接,从postinstall调用多个脚本: { "scripts": { "script1": "", "script2": "", "postinstall": "script1 && script2" } } 这应该可以在Window

每当我运行npm安装时,它都会运行npm运行postinstall。如何添加自定义安装后脚本?因此,在运行npm install之后,它会运行npm run postinstall2?

您可以通过将多个脚本与
&&
链接,从
postinstall
调用多个脚本:

{
  "scripts": {
    "script1": "",
    "script2": "",
    "postinstall": "script1 && script2"
  }
}

这应该可以在Windows和Unix(Linux、macOS)终端上运行。

不,我的意思是,在完成安装后,如何让npm安装调用postinstall以外的脚本。@Jasmine有什么意义?只需将其他脚本中的任何内容放入
“postinstall”
。。。或者,如果您真的很在意,那么“postinstall”:“npm运行postinstall2”,但同样没有意义。