我再也无法初始化React项目了



很长一段时间以来,我一直无法初始化react项目,甚至无法使用npm初始化项目,因为我无法解决多个错误。最初,它是从我必须更新的npm和node-js版本开始的。我在全局范围内卸载了create-react应用程序,然后重新安装了它。但当我用create-rect应用程序启动创建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缓存清理——强制历史清理,我试图在根模式下初始化react,我输入了命令sudo chown-R 1000:1000"/root/.npm";如前所述,但我仍然无法初始化我的项目react

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

sudo apt-get清除节点

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

最新更新