npm init:npm
For create package.json file which will recode the dependence.json
npm install:spa
You can also write like:code
npm i
This is a shortcut way to write npm install.blog
For example. we want to install undersocre.jsip
npm install -S underscore
The way '-S' works is it will write down the dependence into the package.json we just create:ci
{ "name": "commonJSBroswerfiy", "version": "0.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "MIT", "dependencies": { "underscore": "^1.7.0" } }
dev-dependence:bower
npm install -D bower
'-D' is to add dependence into devdependence which only available for the co-work.underscore
{ "name": "commonJSBroswerfiy", "version": "0.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "MIT", "dependencies": { "underscore": "^1.7.0" }, "devDependencies": { "bower": "^1.3.12" } }
If we have package.json, other people download our project and they just need to run:it
npm i
They can install all the dependence.