cnpm安装报错 npm ERR! enoent ENOENT: no such file or directory, access 'D:\Develop\nodejs\node_global……
程序员文章站
2022-05-30 09:47:59
...
一、问题描述
- windows命令行下运行指令:
npm install -g cnpm --registry=https://registry.npm.taobao.org
- 出现如下错误:
npm ERR! path D:\Develop\nodejs\node_global\node_modules\cnpm\node_modules\getpass
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access 'D:\Develop\nodejs\node_global\node_modules\cnpm\node_modules\getpass'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! D:\Develop\nodejs\node_cache\_logs\2019-08-14T14_04_21_545Z-debug.log
二、解决问题
1. 依次输入以下命令:
npm set registry https://registry.npm.taobao.org # 注册模块镜像
npm set disturl https://npm.taobao.org/dist # node-gyp 编译依赖的node源码镜像
npm cache clean --force # 清空缓存
2. 若上述方法任然报错,那么将no such file or directory,access中指明的文件路径中的node_modules手动删除,最后再npm命令从新安装淘宝cnpm淘宝镜像。