npm postinstall因多个命令而失败

kai*_*ser 13 bash command-line-interface node.js npm post-install

在我的内部composer.json,有一个postinstall如下所示的钩子设置:

"scripts" : {
    "dist" :        "node dist; node_modules/.bin/doccoh src/package.js",
    "postinstall" : "node_modules/.bin/grunt setup || true; node_modules/.bin/bower install",
    "start" :       "node server.js"
}
Run Code Online (Sandbox Code Playgroud)

每当我运行它(在Git/Gnu Bash CLI的Win上)时,我就会结束

command not found. either the command was written wrong or couldn't be found

来自德国CLI错误的粗略翻译.

我尝试将它拆分成多个;/分号分隔的部分,然后首先cd进入该目录,但它最终会出现相同的错误消息.postinstall用简单替换整个命令集ls确实有效.所以我问题可能是分号分离或命令的错误使用.但总的来说,我不知道出了什么问题.

注意:我在全球范围内安装了grunt-cli0.1.9 grunt版本和0.4.1版本.

Tuc*_*lly 30

我回答有点迟,但是如果你在Windows上,使用&&执行单行上的多个命令

postinstall: "some command && some other -c"
Run Code Online (Sandbox Code Playgroud)

  • @Plato的`&&`运算符也适用于*nix系统. (10认同)
  • 你知道如何通过跨平台支持来做到这一点吗? (5认同)

小智 2

我在寻找东西时遇到了这个问题,并认为这可能对其他人有帮助。我发现当事情变得有点复杂时,转移到 postinstall.js 文件更容易。这使得处理前进的事情变得更容易。

  • 介意提交[编辑]并更详细地描述您的流程吗?提前致谢。 (4认同)