【发布时间】: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