美文网首页
npm 环境

npm 环境

作者: 代瑶 | 来源:发表于2019-07-08 15:24 被阅读0次

配置环境

  1. 修改默认的全局目录
    npm config set prefix D:/node/nodejs/node_global/ //全局包目录,就在node安装目录新建了个nodejs文件夹存放
    npm config set cache D:/ndoe/nodejs/node_cache/ //全局包缓存目录,就在node安装目录新建了个nodejs文件夹存放

检查是否设置成功

npm config get prefix

npm config get cache

2.配置环境变量
先创建node_modules文件夹
在【系统变量】下新建【NODE_PATH】,输入【D:/node/nodejs/node_global/node_modules】
将【用户变量】下的【Path】的【C:/user/AppData/Roaming/npm】修改为【D:/node/nodejs/node_global】

3.测试进行模块全局安装
npm install express -g -d

4.清理缓存 重启机器
npm cache clean清理缓存

取消代理
npm config delete proxy
npm config delete https-proxy

1.临时使用
npm --registry https://registry.npm.taobao.org install express

2.持久使用
npm config set registry https://registry.npm.taobao.org

3.通过cnpm使用
npm install -g cnpm --registry=https://registry.npm.taobao.org

4.还原成默认URL
npm config set registry https://registry.npmjs.org

  1. 删除淘宝镜像
    npm config delete registry
    npm config delete disturl
    删除cnpm
    npm uninstall cnpm -g

相关文章

网友评论

      本文标题:npm 环境

      本文链接:https://www.haomeiwen.com/subject/arzohctx.html