npm i tnpm -g --registry=https://registry.antgroup-inc.cn报错

先看报错提示:
C:\Users\chai>npm i tnpm -g --registry=https://registry.antgroup-inc.cn
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path D:\nodejs\node_cache_cacache
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir ‘D:\nodejs\node_cache_cacache’
npm ERR! at async Object.mkdir (node:internal/fs/promises:855:10)
npm ERR! at async makeTmp (D:\nodejs\node_modules\npm\node_modules\cacache\lib\content\write.js:156:3)
npm ERR! at async handleContent (D:\nodejs\node_modules\npm\node_modules\cacache\lib\content\write.js:103:15)
npm ERR! Error: EPERM: operation not permitted, mkdir ‘D:\nodejs\node_cache_cacache’
npm ERR! at async Object.mkdir (node:internal/fs/promises:855:10)
npm ERR! at async makeTmp (D:\nodejs\node_modules\npm\node_modules\cacache\lib\content\write.js:156:3)
npm ERR! at async handleContent (D:\nodejs\node_modules\npm\node_modules\cacache\lib\content\write.js:103:15) {
npm ERR! errno: -4048,
npm ERR! code: ‘EPERM’,
npm ERR! syscall: ‘mkdir’,
npm ERR! path: ‘D:\nodejs\node_cache\_cacache’
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 editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! Log files were not written due to an error writing to the directory: D:\nodejs\node_cache_logs
npm ERR! You can rerun the command with --loglevel=verbose to see the logs in your terminal

错误分析
错误提示 EPERM: operation not permitted, mkdir ‘D:\nodejs\node_cache_cacache’ 表示 npm 试图在 D:\nodejs\node_cache_cacache 路径下创建一个文件夹,但是没有权限。这通常是因为当前用户没有足够的权限来在该目录下创建文件夹。

以下是一些可能的解决方案:
1.以管理员身份运行命令提示符或 PowerShell:

  • 右键点击“命令提示符”或“PowerShell”,然后选择“以管理员身份运行”。

  • 在打开的管理员命令提示符或PowerShell窗口中再次运行你的npm安装命令。

2.检查并修改文件夹权限:
(备注):小编我就是这么解决的!!!

  • 导航到 D:\nodejs\node_cache 文件夹。
  • 右键点击该文件夹,选择“属性”。
  • 切换到“安全”选项卡。
  • 点击“编辑”来更改权限,确保你的用户账户有足够的权限来创建和修改文件夹。
  • 如果你不确定如何设置,可以尝试给予“完全控制”权限,但请注意这可能会带来安全风险。

3.关闭可能干扰的程序:

  • 确保没有文本编辑器、防病毒软件或其他程序正在使用或锁定 D:\nodejs\node_cache 文件夹。

  • 如果有,请关闭这些程序后再尝试运行npm命令。

4.检查路径是否正确:

  • 确保 D:\nodejs\node_cache 路径存在,并且你的用户账户对其有访问权限。
  • 如果不存在,请创建该路径,或者选择一个你已经有权限的路径来设置npm缓存。

5.使用 --loglevel=verbose 参数重新运行命令:

  • 如果上述方法都不能解决问题,你可以在npm命令后添加 --loglevel=verbose
    参数来查看更详细的日志信息,这可能会帮助你进一步诊断问题。

例如,你可以尝试以下命令:

npm i tnpm -g --registry=https://registry.antgroup-inc.cn --loglevel=verbose

请尝试上述方法,并根据需要调整权限或关闭可能干扰的程序。如果问题仍然存在,请仔细检查错误日志以获取更多线索。

  • 19
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值