Tuesday, 2 June 2015

node npm dependencies

Usually when you run npm install locally, it will install all packages of your package.json file, including "dependencies" and "devDependencies".


npm offers "dependencies" and "devDependencies" for purpose. Actually npm also offers "optionalDependencies".  (the only different of optional and other dependencies is that build failures do not cause installation to fail)

 "devDependencies"  is for local testing and running, so you can put your unit test packages and e2e test packages here.

"dependencies" is for production, so you should not put test packages here.

When your run npm install locally, it will install all packages includes "dependencies" and "devDependencies".

But in some server like heroku, they install "devDependencies" packages only (https://devcenter.heroku.com/articles/nodejs-support). That managed by npm model.

You can change that by changing system ENV:  NODE_ENV="production"
or just run npm like this: npm install --production



http://stackoverflow.com/questions/949314/how-to-retrieve-the-hash-for-the-current-commit-in-git
https://docs.npmjs.com/misc/config#production

http://stackoverflow.com/questions/9268259/how-do-you-install-development-only-npm-modules-for-node-js-package-json



No comments:

Post a comment