npm init (this will generate a package.json)

 

Install packages locally

1. see 'import express from 'express'; => 

npm install express

(node modules folder is created, regular dependence included in the project)

2.add dependency that is used throughout the development but not included in the production build  =>

 npm install babel-cli babel-preset-stage-0 babel-preset-es2015 --save-dev

npm package manager

 

install packages globally

npm package manager

install globally in C:\Program Files\nodejs\node_modules\npm?

install react globally => npm install -g react (sudo npm install react -g)

install the CLI tool to create application with react => sudo npm install create-react-app -g

 

update packages

sudo npm install [email protected] -g  (install a package of a particular version)

npm outdated (check dependency only LOCALLY)

npm outdated -g (check dependency only GLOBALLY)

sudo npm install eslint -g

 

removing a package

npm uninstall babel-preset-es2015 

npm instal babel-preset-env --save-dev

 

sematic versioning

1.4.2 means:

1 is major releases

4 is for minor releases

2 is for patch releases

^1.15.4 means:

caret for all minor and patches OK

~1.5.4 means:

tilde for all patches only

 

package.json

package.json is input and package-lock.json is output

 

 

 

 

 

 

 

相关文章: