Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm script running for preinstall, but not for preupdate

Tags:

node.js

npm

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.

like image 979
Pike Avatar asked Jun 14 '12 23:06

Pike


People also ask

How do I run a script defined package in 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.

How do I run a script after npm install?

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/.

Why npm start not working?

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 .

Does npm install automatically add to json?

json, you can re-run npm init -y and the repository field will be added automatically to your package. json.


1 Answers

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

like image 57
qodeninja Avatar answered Sep 30 '22 01:09

qodeninja