简体   繁体   English

npm postinstall使用多个命令失败

[英]npm postinstall fails with multiple commands

Inside my composer.json , there's a postinstall hook setup like the following: 在我的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"
}

Whenever I run it (on Win from Git/Gnu Bash CLI), I end with 每当我运行它时(在Git / Gnu Bash CLI的Win中),我都会以

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

Rough translation from German CLI error. 德语CLI错误的粗略翻译。

I tried splitting it into multiple ; 我尝试将其拆分为多个; /semicolon separated parts and first cd into that directory, but it simply ends up with the same error message. / semicolon将各个部分分开,然后先将cd放入该目录,但是最终只会出现相同的错误消息。 Replacing the whole postinstall command set with a simple ls does work. 用简单的ls代替整个postinstall命令集确实可以工作。 So I guess the problem might be the semicolon separation or a wrong usage of commands. 所以我问题可能是分号分隔或命令使用不正确。 But overall I got no idea what's wrong. 但是总的来说,我不知道怎么了。

Note: I got grunt-cli version 0.1.9 and grunt version 0.4.1 installed globally. 注意:我在全球安装了grunt-cli版本0.1.9和grunt版本0.4.1。

我来晚了一点,但是如果您使用的是Windows,则使用&&在同一行上执行多个命令

postinstall: "some command && some other -c"

I ran into this looking for something and thought this may help other people. 我遇到这个问题是在寻找东西,并认为这可能对其他人有所帮助。 I have found it easier to move to postinstall.js files as things get a little complicated. 我发现,随着事情变得有些复杂,移至postinstall.js文件更加容易。 This makes it easier to deal with moving forward. 这使得更容易应对前进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM