npm 常用命令 常用知识

1、常用命令

参考:

https://www.cnblogs.com/BJQE/p/16510627.html

https://zhuanlan.zhihu.com/p/442407879

1. 清除缓存

有时候安装或卸载模块时,出现错误,有可能是缓存未清理的缘故。

npm cache clean --force

2. 更换npm源地址

//换为淘宝镜像
npm config set registry http://registry.npmmirror.com/
//恢复为默认源
npm config set registry https://registry.npmjs.org 
//查看镜像源地址
npm config get registry

2、知识点

2.1 npm i和npm install的区别

实际使用的区别点主要如下(windows下):
1. 用npm i安装的模块无法用npm uninstall删除,用npm uninstall i才卸载掉
2. npm i会帮助检测与当前node版本最匹配的npm包版本号,并匹配出来相互依赖的npm包应该提升的版本号
3. 部分npm包在当前node版本下无法使用,必须使用建议版本
4. 安装报错时intall肯定会出现npm-debug.log 文件,npm i不一定

转自:https://blog.csdn.net/chern1992/article/details/79193211

2.2 npm 安装

npm i adm-zip

安装成功后会在 package.json 以及 package-lock.json 文件中添加相关包信息

例如:

 

posted @ 2023-08-25 13:53  PrintY  阅读(13)  评论(0编辑  收藏  举报