NPM常用命令

发布时间:2019-07-02 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了NPM常用命令脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

NPM常用命令整理

操作环境

操作环境:Windows系统(Win7、Win10)
所有的命令都再 CMD 或者 PowerShell 下面操作

NPM设置相关操作

设置全局安装环境

/* 设置 */
npm config set prefix "D:Program Filesnodejsnode_modulesnode_global"
/* 查看 */
npm root -g

设置npm 的镜像

/* 设置 */
npm config set registry https://registry.npm.taobao.org
/* 查看 */
npm config get registry

设置安装的缓存路径

/* 设置 */
npm config set cache "D:Program Filesnodejsnode_modulesnode_cache"
/* 查看 */
npm config get cache

清理缓存

npm cache clean

NPM安装第三方包

/* 全局安装 */
npm install -g typescript 
/* 普通安装 */
npm install typescript

/* 查看已安装的模块 */
npm list -g --depth 0

/* 查找指定的模块 */
npm ls -graceful-fs
npm ls minimatch

/* 全局查找指定的模块 */
npm ls -g node-gyp

NPM 管理插件

NPM的管理工具

/* NPM registry 管理工具 */
npm install -g nrm

nrm help
nrm ls

/* 切换到 cnpm */
nrm use cnpm
/* 浏览器打开首页 */
nrm home    

清理 node_modules

window 删除顽固 node_modules
/* 安装 */
npm install -g rimraf

/* 跳转到指定的目录下 */
rimraf node_modules/

所安装的包的版本

/* 安装 */
npm i -g npm-check
/* 查看 */
npm-check -g

安装开发插件

typescrip 编译环境

/* 下载安装 */
npm i -g typescrip 
/* 查看版本 */
tsc -v
/* 编译 ts 文件 */
tsc hello.ts

Angular 相关

-- 新建只有空文件工程 没有 node_modules
ng new auction --dir=.

-- 带有 路由的工程
ng new router --routing 

-- 新建一个工程,但是跳过安装 node_modules 的依赖
ng  new my-app --skip-install

ng set --global warnings.versionMismatch=false

备注
1.NPM官网
2.NPM官方文档
3.npm-check说明文档
4.nrm说明文档
5.Angular环境安装说明

脚本宝典总结

以上是脚本宝典为你收集整理的NPM常用命令全部内容,希望文章能够帮你解决NPM常用命令所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: