当我们新安装好node之后,可能会遇到npm install 下载依赖包的时候,显示下面这种报错:
npm WARN registry Unexpected warning for http://registry.npmjs.org/:ot permitted, open 'D:\\Software\\node\\node_cache\\_cacache\\tmp\\d
npm WARN registry Using stale data from http://registry.npmjs.org/ d
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path D:\Software\node\node_cache\_cacache\tmp\19f512e6
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'D:\Software\no
npm ERR! [OperationalError: EPERM: operation not permitted, open 'D'] {
npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\S
{
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'D:\\Software\\node\\node_cache\\_cacache\\tmp\\1
npm ERR! },
npm ERR! isOperational: true,
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'D:\\Software\\node\\node_cache\\_cacache\\tmp\\19f
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text e
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please do
npm ERR! permissions of the file and its containing directories, or
npm ERR! the command again as root/Administrator.
那么这个问题是为什么呢?
npmrc 这个文件是我们没有配置好,导致的不能使用,我们应该再安装完node之后,使用cmd管理员身份打开,然后配置一下变量
npm config set cache "D:\Software\node\node_cache"
npm config set prefix "D:\Software\node\node_global"
npm install -g cnpm --registry=https://registry.npm.taobao.org
然后看一下node环境配置
解决办法:
在 c盘目录下找到那个默认隐藏的文件如C:\Users{账户}\下的.npmrc文件 把它删除掉 记住 不是node.js安装目录下的那个!