Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM : how to just run post-install?

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

like image 474
noelm Avatar asked Jun 23 '15 10:06

noelm


People also ask

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

Can I run npm install?

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.

What is post install script?

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) }

How do I do a clean install of npm?

There are two ways to clean up the node_modules folder: Delete the folder and reinstall. Use npm prune (starting with npm version 6)


1 Answers

You can run individual script entries using npm run SCRIPTNAME:

$ npm run postinstall 
like image 131
robertklep Avatar answered Oct 10 '22 10:10

robertklep