1.安装指定版本
npm install jquery@3.0.0 --save
2.全局安装
npm install xxx -g
3.本地安装
npm install xxx
4.信息写入
npm install xxx --save
#简写 npm install xxx -S
#--save是将依赖包名称添加到package.json文件的dependenies,项目发布后还依赖的包
npm install xxx --save-dev
#简写 npm install xxx -D
#--save-dev将依赖包名称添加到package.json文件的devDependenies,开发时依赖的包,等项目上线则不会使用,如项目中使用的 gulp , 压缩css、js 的模块等在项目上线后则不会使用
npm install 默认会安装2种依赖
5.指定源安装
npm install highcharts --save --registry=https://maven.xxx.com.cn/repository/npmjs/
6.设置淘宝源
npm config set registry https://registry.npm.taobao.org
7.package.json版本符号说明 如果某个包只能接受补丁更新,需要~,如果可以接受小范围更新,用^,如果没有限制,用*
8.yarn的优点 并行安装,速度快;安装版本统一;更加简洁的输出;多注册来源处理;更好的语义化; 命令对比
参考文章
版本号介绍
安装命令
docs.npmjs.com/downloading… blog.csdn.net/xuaner8786/…
npm和yarn对比 shawnzhou.world/2021/09/28/…