Skip to content

npm常用命令

查看npm版本

npm -v
npm -v

初始化包文件,加上-y可以跳过问答步骤

npm init -y
npm init -y

安装项目依赖

npm install
npm install

查看当前项目安装了哪些包,-g查看全局

npm list
npm list

查看npm 命令

npm --help
npm --help

更新包

npm update 包名
npm update 包名

卸载包

npm uninstall 包名
npm uninstall 包名

查看配置信息

npm config list
npm config list

查看镜像

npm config get registry
npm config get registry

安装镜像

//这个坏了报错,需要换一个镜像源2024.1.22过期,https无法用
npm install cnpm -g --registry= https://registry.npm.taobao.org

//方法一:需要换一个源
npm install -g cnpm --registry=https://registry.npmmirror.com

//或者用官方的源
npm install -g cnpm --registry=https://registry.npmjs.org

//方法二:禁用ssl
npm config set strict-ssl false
//这个坏了报错,需要换一个镜像源2024.1.22过期,https无法用
npm install cnpm -g --registry= https://registry.npm.taobao.org

//方法一:需要换一个源
npm install -g cnpm --registry=https://registry.npmmirror.com

//或者用官方的源
npm install -g cnpm --registry=https://registry.npmjs.org

//方法二:禁用ssl
npm config set strict-ssl false

修改镜像,设置为其他镜像

npm config set registry https://registry.npmmirror.com/
npm config set registry https://registry.npmmirror.com/

程序员小洛文档