npm postinstall fails with multiple commands

14k views Asked by At

Inside my composer.json, there's a postinstall hook setup like the following:

"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

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

Rough translation from German CLI error.

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. Replacing the whole postinstall command set with a simple ls does work. 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.

2

There are 2 answers

3
Tucker Connelly On

I'm a bit late to answer, but if you're on Windows, multiple commands on a single line are executed with the use of &&

postinstall: "some command && some other -c"
2
Doug On

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. This makes it easier to deal with moving forward.