`
fantaxy025025
  • 浏览: 1328086 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类

nodejs_cnpm导致node的prefix和cache和node_global配置环境变量不起作用

 
阅读更多

 

cnpm的介绍:

http://npm.taobao.org/这是一个完整 npmjs.org 镜像,你可以用此代替官方版本(只读),同步频率目前为 10分钟 一次以保证尽量与官方服务同步。

 

cnpm的配置:

alias cnpm="npm --registry=https://registry.npm.taobao.org \

  --cache=$HOME/.npm/.cache/cnpm \

  --disturl=https://npm.taobao.org/dist \

  --userconfig=$HOME/.cnpmrc"

 

问题:

默认的配置+npm,没有问题:

$ npm config list -l

; cli configs

long = true

user-agent = "npm/2.14.12 node/v4.3.1 win32 x64"

 

; userconfig C:\Users\xxx\.npmrc

cache = "D:\\nodejs\\node_cache"

prefix = "D:\\nodejs\\node_global"

 

; builtin config undefined

; prefix = "C:\\Users\\xxx\\AppData\\Roaming\\npm" (overridden)

 

; default values

access = null

always-auth = false

bin-links = true

browser = null

ca = null

; cache = "C:\\Users\\xxx\\AppData\\Roaming\\npm-cache" (overridden)

cache-lock-retries = 10

cache-lock-stale = 60000

cache-lock-wait = 10000

cache-max = null

cache-min = 10

cafile = undefined

cert = null

color = true

depth = null

description = true

dev = false

editor = "notepad.exe"

engine-strict = false

fetch-retries = 2

fetch-retry-factor = 10

fetch-retry-maxtimeout = 60000

fetch-retry-mintimeout = 10000

force = false

git = "git"

git-tag-version = true

global = false

globalconfig = "D:\\nodejs\\node_global\\etc\\npmrc"

globalignorefile = "D:\\nodejs\\node_global\\etc\\npmignore"

group = 0

heading = "npm"

https-proxy = null

if-present = false

ignore-scripts = false

init-author-email = ""

init-author-name = ""

init-author-url = ""

init-license = "ISC"

init-module = "C:\\Users\\xxx\\.npm-init.js"

init-version = "1.0.0"

json = false

key = null

link = false

local-address = undefined

loglevel = "warn"

; long = false (overridden)

message = "%s"

node-version = "4.3.1"

npat = false

onload-script = null

optional = true

parseable = false

; prefix = "D:\\nodejs" (overridden)

production = false

proprietary-attribs = true

proxy = null

rebuild-bundle = true

registry = "https://registry.npmjs.org/"

rollback = true

save = false

save-bundle = false

save-dev = false

save-exact = false

save-optional = false

save-prefix = "^"

scope = ""

searchexclude = null

searchopts = ""

searchsort = "name"

shell = "C:\\Windows\\system32\\cmd.exe"

shrinkwrap = true

sign-git-tag = false

spin = true

strict-ssl = true

tag = "latest"

tag-version-prefix = "v"

tmp = "D:\\cygwin64\\tmp"

umask = 0

unicode = true

unsafe-perm = true

usage = false

user = 0

; user-agent = "npm/{npm-version} node/{node-version} {platform} {arch}" (overridden)

userconfig = "C:\\Users\\xxx\\.npmrc"

version = false

versions = false

viewer = "browser"

 

但是自己配置node环境变量+cnpm就会出现问题。

$ cnpm config list -l

; cli configs

cache = "D:\\home\\xxx\\.npm\\.cache\\cnpm"

disturl = "https://npm.taobao.org/dist"

long = true

registry = "https://registry.npm.taobao.org/"

user-agent = "npm/2.14.12 node/v4.3.1 win32 x64"

userconfig = "D:\\home\\xxx\\.cnpmrc"

 

; builtin config undefined

prefix = "C:\\Users\\xxx\\AppData\\Roaming\\npm"

 

; default values

access = null

always-auth = false

bin-links = true

browser = null

ca = null

; cache = "C:\\Users\\xxx\\AppData\\Roaming\\npm-cache" (overridden)

cache-lock-retries = 10

cache-lock-stale = 60000

cache-lock-wait = 10000

cache-max = null

cache-min = 10

cafile = undefined

cert = null

color = true

depth = null

description = true

dev = false

editor = "notepad.exe"

engine-strict = false

fetch-retries = 2

fetch-retry-factor = 10

fetch-retry-maxtimeout = 60000

fetch-retry-mintimeout = 10000

force = false

git = "git"

git-tag-version = true

global = false

globalconfig = "C:\\Users\\xxx\\AppData\\Roaming\\npm\\etc\\npmrc"

globalignorefile = "C:\\Users\\xxx\\AppData\\Roaming\\npm\\etc\\npmignore"

group = 0

heading = "npm"

https-proxy = null

if-present = false

ignore-scripts = false

init-author-email = ""

init-author-name = ""

init-author-url = ""

init-license = "ISC"

init-module = "C:\\Users\\xxx\\.npm-init.js"

init-version = "1.0.0"

json = false

key = null

link = false

local-address = undefined

loglevel = "warn"

; long = false (overridden)

message = "%s"

node-version = "4.3.1"

npat = false

onload-script = null

optional = true

parseable = false

; prefix = "D:\\nodejs" (overridden)

production = false

proprietary-attribs = true

proxy = null

rebuild-bundle = true

; registry = "https://registry.npmjs.org/" (overridden)

rollback = true

save = false

save-bundle = false

save-dev = false

save-exact = false

save-optional = false

save-prefix = "^"

scope = ""

searchexclude = null

searchopts = ""

searchsort = "name"

shell = "C:\\Windows\\system32\\cmd.exe"

shrinkwrap = true

sign-git-tag = false

spin = true

strict-ssl = true

tag = "latest"

tag-version-prefix = "v"

tmp = "D:\\cygwin64\\tmp"

umask = 0

unicode = true

unsafe-perm = true

usage = false

user = 0

; user-agent = "npm/{npm-version} node/{node-version} {platform} {arch}" (overridden)

; userconfig = "C:\\Users\\xxx\\.npmrc" (overridden)

version = false

versions = false

viewer = "browser"

 

其中:

userconfig = "C:\\Users\\xxx\\.npmrc"

此文件的内容为自己的配置:

prefix=D:\nodejs\node_global
cache=D:\nodejs\node_cache

 

原因: 配置的参数,在win下出现了问题:

alias cnpm="npm --registry=https://registry.npm.taobao.org \

  --cache=$HOME/.npm/.cache/cnpm \

  --disturl=https://npm.taobao.org/dist \

  --userconfig=$HOME/.cnpmrc"

cache指定了,没有考虑用户自己配置的情况。

userconfig也指定了,同上。

 

解决方法:

去掉这俩参数。重新试了一下,好了~~

 

注意事项:

默认安装win下的node,会配置用户的环境变量,指向node_global目录。

若自己改了默认配置,需要指定环境变量啊。

 

q

e

e

w

q

t

3

 

分享到:
评论

相关推荐

    基于net的超市管理系统源代码(完整前后端+sqlserver+说明文档+LW).zip

    功能说明: 环境说明: 开发软件:VS 2017 (版本2017以上即可,不能低于2017) 数据库:SqlServer2008r2(数据库版本无限制,都可以导入) 开发模式:mvc。。。

    LABVIEW程序实例-公式节点.zip

    labview程序代码参考学习使用,希望对你有所帮助。

    大米商城开源版damishop(适合外贸)

    大米外贸商城系统 简称damishop 完全开源版,只需做一种语言一键开启全球133中语言自动翻译功能,价格实现自动汇率转换,集成微信支付宝 paypal以及国外主流支付方式,自带文章博客系统。 软件架构 基于MVC+语言包模式,增加控制台,API导入产品方便对接其他系统(带json示例数据)。 使用要求 PHP7.4+ MYSQL5.6+ REDIS(可选) 安装方法 composer install 打开安装向导安装 http://您的域名/install 特色 1、缓存层增加时间与批量like删除 2、API产品导入方便对接其他系统 3、增加控制台命令行,命令行生成语言翻译包 4、后台一键开启自动翻译模式,支持全球133中语言,由于google代理翻译需要收费,这个功能需要付费。 5、可选购物车与ajax修改购物车产品 6、一键结算checkout 7、增加网站前台自定义路由 方便seo 更新日志 v3.9.7 集成鱼码支付接口,方便个人站长即使收款到账使用 v3.9.3 更新内容 1:增加ueditor与旧编辑器切换 2:增加可视化布局插

    LABVIEW程序实例-通过全局变量接收数据.zip

    labview程序代码参考学习使用,希望对你有所帮助。

    LABVIEW程序实例-日历控件.zip

    labview程序代码参考学习使用,希望对你有所帮助。

    毕设和企业适用springboot人工智能客服系统类及旅游规划平台源码+论文+视频.zip

    毕设和企业适用springboot人工智能客服系统类及旅游规划平台源码+论文+视频

Global site tag (gtag.js) - Google Analytics