npm postinstall因多个命令而失败

时间:2013-09-04 18:45:51

标签: node.js bash command-line-interface 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"
}

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

  

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

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

我尝试将其拆分为多个; /分号分隔部分,并将第一个cd拆分为该目录,但它最终会出现相同的错误消息。用简单的postinstall替换整个ls命令集确实有效。所以我猜测问题可能是分号分离或命令的错误用法。但总的来说,我不知道出了什么问题。

注意:我在全球范围内安装了grunt-cli版本0.1.9和grunt版本0.4.1。

2 个答案:

答案 0 :(得分:30)

我回答有点迟,但是如果你在Windows上,使用&&

执行单行上的多个命令
postinstall: "some command && some other -c"

答案 1 :(得分:2)

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

相关问题