npm 常用命令

查看npm版本

npm -v

npm初始化项目

npm init

npm安装模块

npm install jquery
npm install jquery@1.9.1 --save-dev

npm卸载模块

npm uninstall jquery 卸载模块,但不卸载模块留在package.json中的对应信息
npm uninstall jquery -g 卸载全局模块
npm uninstall jquery --save 卸载模块,同时卸载留在package.json中dependencies下的信息
npm uninstall jquery --save-dev 卸载模块,同时卸载留在package.json中devDependencies下的信息

npm更新模块

npm update jquery 更新最新版本的jquery
npm update jquery@2.1.0 更新到指定版本号的jquery
npm install jquery@latest 可以直接更新到最新的版本

npm查看命令

npm root 查看项目中模块所在的目录
npm root -g 查看全局安装的模块所在目录
npm list 或者 npm ls 查看本地已安装模块的清单列表
npm view jquery dependencies 查看某个包对于各种包的依赖关系
npm view jquery version 查看jquery最新的版本号
npm view jquery versions 查看所有jquery的版本号
npm view jquery 查看最新的jquery版本的信息
npm info jquery 查看jquery的详细信息,等同于上面的npm view jquery
npm list jquery 或者 npm ls jquery 查看本地已安装的jquery的详细信息
npm view jquery repository.url 查看jquery包的来源地址

npm其他命令

npm cache clean 清除npm的缓存
npm prune 清除项目中没有被使用的包
npm outdated 检查模块是否已经过时
npm repo jquery 会打开默认浏览器跳转到github中jquery的页面
npm docs jquery 会打开默认浏览器跳转到github中jquery的README.MD文件信息
npm home jquery 会打开默认浏览器跳转到github中jquery的主页
posted @ 2021-06-21 08:40  胡勇健  阅读(95)  评论(0编辑  收藏  举报