【问题标题】:Npm Error when I try to create the react app当我尝试创建反应应用程序时出现 Npm 错误
【发布时间】:2022-01-22 22:16:47
【问题描述】:

我正在尝试开始创建 react 应用,但我从 npm 收到此消息,请有人帮忙!

npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /Users/fabiodiceglie/.npm/_cacache/content-v2/sha1/17/4b
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR!   sudo chown -R 501:20 "/Users/fabiodiceglie/.npm"

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/fabiodiceglie/.npm/_logs/2022-01-22T10_33_07_875Z-debug-0.log

【问题讨论】:

  • 运行 npm i tar 更新您的 tar 并消除警告
  • 不工作:(还是同样的错误

标签: javascript node.js reactjs npm terminal


【解决方案1】:

所以你这里有 2 个问题。

问题 1 与 create-react-app 有关。支持 create-react-app 的库是 react-scripts。作为 react-scripts 的一部分,使用了 lib tar。 react-scripts 正在使用不再获得安全更新的过期版本的 tar。没关系,因为它应该只用于开发,您应该构建它并将其用于生产。

第二个问题是您的 npm 缓存文件夹归 root 所有,因此非 root 用户不能使用它。 您应该运行:
sudo chown -R 501:20 "/Users/fabiodiceglie/.npm"
修复它,然后你应该更新 npm:
npm install npm@latest -g
这样如果您以后某个时间再次以 root 身份运行,您就不会遇到此问题。

【讨论】:

  • 一切都解决了,谢谢!
猜你喜欢
  • 1970-01-01
  • 2021-02-13
  • 1970-01-01
  • 2020-10-18
  • 2021-08-30
  • 1970-01-01
  • 1970-01-01
  • 2021-08-16
  • 2022-01-18
相关资源
最近更新 更多