常见报错
npm ERR! Log files were not written due to an error writing to the directory: C:\nodejs\node_cache_logs
win10 + nodejs18
安装好了node之后,配置淘宝源报错,当然你可能执行其他命令也是报错:
bash
C:\obj\node\mysite>npm install -g cnpm --registry=https://registry.npm.taobao.org
npm ERR! code ENOENT
npm ERR! syscall mkdir
npm ERR! path C:\obj\node\mysite\'C:\nodejs\node_global'
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, mkdir 'C:\obj\node\mysite\'C:\nodejs\node_global''
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Log files were not written due to an error writing to the directory: C:\nodejs\node_cache\_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
解决办法就是,删除C:\Users\用户\
文件夹的.npmrc
和.node_repl_history
这俩文件。
然后打开cmd终端,执行:
bash
npm cache clean --force
再重新尝试命令即可:
bash
npm install -g cnpm --registery=https://registery.npm.taobao.org
bash
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
s), run: npm audit fix --force
Run npm audit
for details.