I am trying to create two separate npm commands to start my NodeJS project locally on the dev machine and in production mode. I want to be able to pass arguments to the machine separately to serve the right dependencies - which could be a CDN in production OR my local machine.
Here's what I am looking to have in package.json
"run": "node ./server/app.js", /* for running locally*/
"start": "node ./server/app.js", /* for running in production*/
If I try to call npm run - it creates this error:
npm ERR! npm run-script [<pkg>] <command>
npm ERR! not ok code 0
I also want to be able to send commandline argumentswhich would contain a URL.
You are not doing it right.
To call custom scripts, you have to run
npm run-script run
Your package.json should have:
"scripts": {
"start": "node ./server/app.js",
"run": "node ./server/app.js"
}
See: https://npmjs.org/doc/cli/npm-run-script.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With