![](/img/trans.png)
[英]I couldn't create react app by using the cmd “npx create-react-app”
[英]Create-react-app couldn't generate and has errors
我有一段時間沒有編寫代碼了,我想重新開始。 當我嘗試運行: npx create-react-app my-app 時,這就是返回給我的:
Creating a new React app in /Users/kyhongle/Desktop/my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /Users/kyhongle/.npm/_cacache/content-v2/sha512/0b/62
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/kyhongle/.npm"
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/kyhongle/.npm/_logs/2020-03-18T21_14_29_829Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting my-app/ from /Users/kyhongle/Desktop
Done.
我不知道如何從這里開始。 在此之前我做了一些可能不應該做的事情,我運行了 sudo npm cache clean -f。 我認為這可能是導致這個問題的原因。 如果有人可以幫助我扭轉這種情況,我將不勝感激!
答案就在你的蹤跡中:
npm 錯誤! 要永久解決此問題,請運行:
npm 錯誤! sudo chown -R 501:20 "/Users/kyhongle/.npm"
sudo chown -R 501:20 "/Users/kyhongle/.npm"
而且我很確定您不需要將npm cache clean -f
作為sudo
,以供將來參考。
代碼 EACCES 是權限錯誤代碼。
首先,您可以嘗試sudo npx create-react-app my-app
。
或者在您的sudo chown -R 501:20 "/Users/kyhongle/.npm"
,嘗試運行sudo chown -R 501:20 "/Users/kyhongle/.npm"
以遞歸方式更改目錄及其文件的所有者。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.