本地安装: npm install package-name
全局全装: npm install -g package-name
举个栗子
全局安装 React项目的脚手架 npm install -g create-react-app
npm install iview@1.0.1 --save
cnpm install iview@2.13.0 --save //注:重新安装会覆盖旧的版本,比如版本会覆盖上面的1.0.1
升级: npm update
卸载: npm uninstall
例如:
包依赖管理,通过package.json
例如:npm uninstall babel-plugin-import -S//卸载了一个生成包
{
"name": "sanzhong",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"dev": "webpack-dev-server --progress --config webpack.config.dev.js --port 6008 --open --hot"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"css-loader": "^0.28.11",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.2.0",
"style-loader": "^0.20.3",
"url-loader": "^1.0.1",
"vue-lazyload": "^1.2.3",
"vue-loader": "^14.2.2",
"vue-template-compiler": "^2.5.16",
"webpack": "^3.11.0",
"webpack-dev-server": "^2.11.2"
},
"dependencies": {
"axios": "^0.18.0",
"element-ui": "^2.3.4",
"iview": "^2.13.0",
"jquery": "^3.3.1",
"moment": "^2.22.1",
"v-distpicker": "^1.0.16",
"vue-lazyload": "^1.2.3",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
}
}