I'm practicing my English ability lately in order to be recruited by a foreign company for my next job-hopping,if there is anything that I did't express precisely, please pardon me.node
There are several falgs that you should know about:web
a.Install with the "-g" flag, means package will be installed globally.
Install with it when you are going to use command line, such as "grunt".npm init -g [packgeName]
express
b.Install Without the "-g" flag, means package will be installed in local node module for your application.
Install without it when you are going to require the package by using "require()" statement in your application.npm init [packageName]
npm
Install with the "--save" flag, means it will create a "dependencies" section in your "package.json" file, and add the package you installed to it.
When someone else use your application or develop against it, they will have a complete list of dependencies that you build against.npm init [packageName] --save
json
Install with the "--save-dev" flag, means it will create a "devDependencies" section in your "package.json" file, and add the package you installed to it.
Use it when you installed something that you need to share with your other developers , but isn't needed on your production server. Such as things that you use for test. npm init [packageName] --save-dev
segmentfault
The meaning of some symbol before the version of your packages:app
e.g:grunt
"devDependencies": { "mocha": "^2.2.5" // meaning: [major version.[minor version].[patch level] }
e.g: "mocha": "^2.2.5" means you will update mocha until >= "2.2.5", but < "3.0.0"ui
e.g: "mocha": "~2.2.5" means you will update mocha until >= "2.2.5", but < "2.3.0"code
e.g: "mocha": "" means you will update mocha to the latest version*
Related:
Create a Node.js Module and Use it Locally
Publish a Node.js Module to the NPM Registry