I have a script referenced in packages.json for a node app.
The script is run fine when I do
npm install
but not for
npm update
The excerpt from packages.json is
"scripts": {
"start": "node app.js",
"preinstall": "node scripts/install.js",
"preupdate": "node scripts/install.js"
}
The whole file is at https://github.com/Pike/outreach/blob/master/package.json.
To define an NPM script, set its name and write the script under the 'scripts' property of your package. json file: To execute your Script, use the 'npm run <NAME-OF-YOUR-SCRIPT>' command. Some predefined aliases convert to npm run, like npm test or npm start, you can use them interchangeably.
You can easily run scripts using npm by adding them to the "scripts" field in package. json and run them with npm run <script-name> . Run npm run to see available scripts. Binaries of locally install packages are made available in the PATH , so you can run them by name instead of pointing to node_modules/.
Check the ignore-script config If you see the start script is present inside your package. json file but still can't run the script, you need to check the console output. If there's no output at all, then you may have the ignore-scripts npm configuration set to true .
json, you can re-run npm init -y and the repository field will be added automatically to your package. json.
As I understand it they've disabled the scripts for npm update (preupdate/postupdate) -- something about best practice...
It's a complete pain in the ass -- they want you to use node-gyp and .gyp files for building node modules -- it has a dependency on python! No thanks!
I'm still banging my head on the keyboard over this -- since we cant install python on our production servers.
Update Python is available on most Linux Distros, not too much of a big deal
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