Repository navigation
Description
I tried to use this in Windows but it fails. I traced the issue to the use of single quotes. Windows doesn't recognize 'just one parm' as a single parameter, but as 3 parameters which with bash/unix would have been typed 'just one parm'. In the example of running "npm run watch" I got an error telling me that 'npm isn't an executable (notice the leading quote). I added some logging and I got this:
C:\usr\local\angular\projects\npm-scripts-example-master>parallelshell 'where npm'
[ 'node',
'C:\\usr\\local\\angular\\projects\\npm-scripts-example-master\\node_modules\\parallelshell\\index.js',
'\'where',
'npm\'' ]
C:\usr\local\angular\projects\npm-scripts-example-master>parallelshell "where npm"
[ 'node',
'C:\\usr\\local\\angular\\projects\\npm-scripts-example-master\\node_modules\\parallelshell\\index.js',
'where npm' ]
As you can see, single quotes and double quotes aren't considered the same in windoze. :-( (You can thank Billy for that.)
So, I was able to get a bit further along by doing something like this:
"watch": "parallelshell \"npm run watch:test -s\" \"npm run watch:build -s\"",
I also noticed that this was frowned upon by npm:
"watch": 'parallelshell "npm run watch:test -s" "npm run watch:build -s"',
It wants the "watch" parameter to start with a double quote and gives this error:
npm ERR! Failed to parse json
npm ERR! Unexpected token '
I also tried with Cygwin and bash provided in Git, without success, and this problem is not just limited to 'parallelshell' but even this fails:
"build": "npm run build:scripts -s && npm run build:styles -s && npm run build:markup -s",
So, in the end even if this seems like a good idea, it didn't work but it would be nice if it did.
Activity
christianseel commentedon Jan 15, 2015
Hey, from my latest experience it works just fine if you replace all
'(single quote) with\"(escaped double quote)…cpu999 commentedon Jan 15, 2015
Christian,
I hope this will help as I am not trying to complain.
I installed your example from the downloaded ZIP. Then I ran "npm
install" to get all the dependencies. The "npm run watch" still fails
but some commands work, like the "npm run build". I tried this on 2
machines as the corporate computer is sometimes tempermental but my
personal computer isn't. I got the same results.
Here is some of the run samples: (I highlighted the command lines but
the email program highlighted what looks like email addresses)
C:\usr\local\angular\projects\npm-scripts-example-master>npm run watch
npm run watch:build -sfailed with exit code 1npm ERR! [email protected] watch:
parallelshell "npm run watch:test -s" "npm run watch:build -s"npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] watch script.
npm ERR! This is most likely a problem with the npm-scripts-example
package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! parallelshell "npm run watch:test -s" "npm run watch:build
-s"
npm ERR! You can get their info via:
npm ERR! npm owner ls npm-scripts-example
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\usr\local\nodejs\node.exe"
"C:\usr\local\nodejs\node_modules\npm\bin\npm-cli.js" "run"
"watch"
npm ERR! cwd C:\usr\local\angular\projects\npm-scripts-example-master
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!
C:\usr\local\angular\projects\npm-scripts-example-master\npm-debug.log
npm ERR! not ok code 0
C:\usr\local\angular\projects\npm-scripts-example-master>npm run
watch:build
npm ERR! [email protected] watch:build:
nodemon -q -w assets/ --ext "." --exec "npm run build"npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] watch:build script.
npm ERR! This is most likely a problem with the npm-scripts-example
package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! nodemon -q -w assets/ --ext "." --exec "npm run build"
npm ERR! You can get their info via:
npm ERR! npm owner ls npm-scripts-example
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\usr\local\nodejs\node.exe"
"C:\usr\local\nodejs\node_modules\npm\bin\npm-cli.js" "run"
"watch:build"
npm ERR! cwd C:\usr\local\angular\projects\npm-scripts-example-master
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!
C:\usr\local\angular\projects\npm-scripts-example-master\npm-debug.log
npm ERR! not ok code 0
C:\usr\local\angular\projects\npm-scripts-example-master>npm run build
generated dist\main.css.map
compiled dist\main.css
rendered dist\index.html
C:\usr\local\angular\projects\npm-scripts-example-master>
Although I would very much like to be able to use npm to configure the
builds, it seems that there still is some reason why other build tools
were developed.
Thanks.
Gerard Perreault
------ Original Message ------
From: "Christian Seel" [email protected]
To: "keithamus/npm-scripts-example"
[email protected]
Cc: "cpu999" [email protected]
Sent: 1/15/2015 1:23:40 PM
Subject: Re: [npm-scripts-example] Doesn't work with Windows (#5)
keithamus commentedon Jan 15, 2015
@cpu999 try downloading the example again, it should work now.
keithamus commentedon Jan 15, 2015
Thanks @christianseel for suggesting the fix 😄
cpu999 commentedon Jan 15, 2015
Actually, it still didn't work. I replaced all the single quotes by " and now the "npm run build" works. However, the "watch:build" still fails. I suspect it may have to do with the use of "nodemon", the "--exec" parameter. If I recall correctly, "exec" requires an executable and "npm" is not one, it is a script.
This is what I had to change it to:
Notice that on the --exec I added "cmd /c" and now it works. However, that makes the build not compatible in both Unix and Windows. I'll let you know if I figure out something.
christianseel commentedon Jan 16, 2015
We had the same issue with nodemon under windows. It seems like you can't execute
npn runfrom nodemon. Thats why we replaced it with watch:like
"watch:build": "watch \"npm run build\" assets/sources"keithamus commentedon Jan 16, 2015
Nodemon has an issue here: remy/nodemon#389. Anyone experiencing this issue with nodemon should file it there - it looks like it may be coming toward a fix, but I'm sure your experiences would help.
Update scripts so that they will run on windows
amg-design commentedon Dec 4, 2017
thanks guys! I had the same issue and now it works!