Just a simple question : in my node.js project, how could I just run the postinstall script, without running install before ?
FYI, this is my package.json :
{ "name": "gestionclientjs", ..., "dependencies": { ... }, "repository": {}, "devDependencies": { ... }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "grunt test", "postinstall" : "bower install && node ./app/server/dbSeed.js", "start": "node app/server/app.js" } }
For now, I run :
npm install
in my project, but I want to run
npm postinstall
when I want (and when I'm sure dependencies are ok).
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/.
npm install downloads a package and it's dependencies. npm install can be run with or without arguments. When run without arguments, npm install downloads dependencies defined in a package. json file and generates a node_modules folder with the installed modules.
A post install script is an Apex class that implements the InstallHandler interface. This interface has a single method called onInstall that specifies the actions to be performed on installation. global interface InstallHandler { void onInstall(InstallContext context) }
There are two ways to clean up the node_modules folder: Delete the folder and reinstall. Use npm prune (starting with npm version 6)
You can run individual script entries using npm run SCRIPTNAME
:
$ npm run postinstall
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