【问题标题】:I can no longer initialize a React project我无法再初始化 React 项目
【发布时间】:2021-12-30 19:16:42
【问题描述】:

很长一段时间以来,我一直无法初始化一个 react 项目,甚至无法使用 npm 初始化一个项目,因为我无法解决多个错误。最初,它从我必须更新的 npm 和 node js 版本开始。我全局卸载了 create-react-app,然后重新安装了它。但是,当我使用 create react app 启动 react 项目的创建时,出现以下错误

glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
errno: -13,
code: 'EACCES',
syscall: 'scandir',
path: '/root/.npm/_logs'
} 
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /root/.npm/_cacache/tmp
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 1000:1000 "/root/.npm"

Creating a new React app in /home/tiffane/Documents/Visi/client.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
errno: -13,
code: 'EACCES',
syscall: 'scandir',
path: '/root/.npm/_logs'
}
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /root/.npm/_cacache/tmp
npm ERR! errno EACCES
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 1000:1000 "/root/.npm"

Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-       template has failed.

Deleting generated file... package.json
Deleting client/ from /home/tiffane/Documents/Visi
Done.

在阅读得到的错误后,我执行了 npm cache clean --force history 来清理内容,我尝试在 root 模式下初始化 react,我输入了命令 sudo chown -R 1000: 1000 "/root /.npm "如所示,但无事可做我仍然无法初始化我的项目反应

【问题讨论】:

    标签: node.js reactjs npm create-react-app


    【解决方案1】:

    我遇到了类似的问题。重新安装节点和 npm 有帮助。 尝试完全删除 node.js:

    sudo apt-get purge 节点

    它会删除软件包和所有配置文件。然后从here下载最新的稳定版本。 那应该可以解决问题。 稍后更新节点,您可以使用nvm

    【讨论】:

    • 清除它后,我应该重新安装它吗??
    • 节点不是包
    • @DevBeginner 你是什么意思?你有什么错误吗??
    • 清除节点后,我重新安装了最新版本的节点..但我得到了同样的错误
    • @DevBeginner 然后我不知道可能出了什么问题。抱歉,我帮不上忙,我对 Linux 不是很有经验。尝试在 Linux 论坛中提问。您的 Linux 发行版甚至可能有一些您可以使用的专门论坛。
    猜你喜欢
    • 2021-06-12
    • 2020-08-29
    • 2020-12-21
    • 1970-01-01
    • 1970-01-01
    • 2015-10-20
    • 2019-06-19
    • 2020-12-22
    • 1970-01-01
    相关资源
    最近更新 更多