Reputation: 431
I have included the next command in my package.json file:
"scripts": {
...
"watch:js": "watch -p ./cartridges/app_skberge_peru/cartridge/client/default/js/*.js -c npm run compile:js",
...
}
When I execute the command in the command line like this:
watch -p './cartridges/app_skberge_peru/cartridge/client/default/js/*.js' -c 'npm run compile:js'
It works perfectly but when I try to do it with:
npm run watch:js
It gives me the next error:
> Watching compile:js'
C:\Users\Ángel - Trabajo\Desktop\VISEO\Proyectos\skberge\code\app_skberge_peru\node_modules\watch\main.js:73
if (err) throw err;
^
Error: ENOENT: no such file or directory, stat 'C:\Users\Ángel - Trabajo\Desktop\VISEO\Proyectos\skberge\code\app_skberge_peru\compile:js''
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] watch:js: `watch -p './cartridges/app_skberge_peru/cartridge/client/default/js/*.js' -c 'npm run compile:js'`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] watch:js script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ángel - Trabajo\AppData\Roaming\npm-cache\_logs\2021-03-08T17_25_59_377Z-debug.log
I'm sure it must be something about formatting inside the quotes but I just can not get what I want.
Thank you !
EDITED:
I tried to execute:
"watch:js": "watch -p \"./cartridges/app_skberge_peru/cartridge/client/default/js/*.js\" -c \"npm run compile:js\""
But I receive the next output:
> [email protected] watch:js C:\Users\aquesada\Desktop\Proyectos\skberge\app_skberge_peru
> watch -p "./cartridges/app_skberge_peru/cartridge/client/default/js/*.js" -c "npm run compile:js"
Usage: watch <command> [...directory] [--wait=<seconds>] [--filter=<file>] [--interval=<seconds>] [--ignoreDotFiles] [--ignoreUnreadable]
It's weird because if I execute what you can see in the output in the command line it works perfectly
> watch -p "./cartridges/app_skberge_peru/cartridge/client/default/js/*.js" -c "npm run compile:js"
Watching started
Upvotes: 0
Views: 144
Reputation: 2863
Did you perhaps install watch
globally?
If yes, you should install it as a development dependency in your project by npm i -D watch
. Make sure your current working directory is in your project.
Then, run the script and it should be fine. If that does not work, try adding npx
to your script, e.g. npx watch -p <args>
.
That error happens because you installed watch
as a global dependency. Because of that, when you run it in the command line, it works.
Upvotes: 1