zl程序教程

您现在的位置是:首页 >  其他

当前栏目

npm 安装 卸载 模块;npm 安装指定版本的包(转载)

安装npm模块 版本 指定 转载 卸载
2023-09-11 14:21:28 时间

来源 https://blog.csdn.net/yihanzhi/article/details/75665959

利用npm 安装删除模块

npm安装模块

  • 【npm install xxx】利用 npm 安装xxx模块到当前命令行所在目录;
  • 【npm install -g xxx】利用npm安装全局模块xxx;

本地安装时将模块写入package.json中:

  • 【npm install xxx】安装但不写入package.json;
  • 【npm install xxx –save】 安装并写入package.json的”dependencies”中;
  • 【npm install xxx –save-dev】安装并写入package.json的”devDependencies”中。

npm 删除模块

【npm uninstall xxx】删除xxx模块; 
【npm uninstall -g xxx】删除全局模块xxx;

 

 

npm 安装指定版本的包

使用 包名@版本号 指定

例如,安装 echarts4.0.0

npm install echarts4.0.0

npm 安装淘宝镜像

npm install -g cnpm --registry=https://registry.npm.taobao.org

改为官方镜像源

npm config set registry https://registry.npmjs.org/

改为淘宝镜像源

npm config set registry http://registry.npm.taobao.org/

npm自身升级

  1. window的升级方法
  2. 使用管理员身份打开powershell
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force//脚本执行策略设置

npm install -g npm-windows-upgrade

npm-windows-upgrade  //更新命令和下面一句起相同作用只是可能版本有差别

npm-windows-upgrade -p -v latest    //升级到最新版本
参考文档:
https://stackoverflow.com/questions/18412129/how-can-i-update-npm-on-windows/31520672#31520672


npm自身版本查看

npm -v


https://blog.csdn.net/yihanzhi/article/details/75665959

https://www.cnblogs.com/shiazhen/p/11942739.html