請幫我解決這個錯誤
安裝 node.js 并將其添加到路徑中后,我在 iterm 上運行了以下命令
npm install -g create-react-app
我收到以下錯誤
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/create-react-app
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/create-react-app'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/amaterasu/.npm/_logs/2022-01-04T08_36_06_018Z-debug.log ```
uj5u.com熱心網友回復:
您需要節點版本 >=14 并且 npm >=5.6 使用命令 npx create-react-app myapp。 https://reactjs.org/docs/create-a-new-react-app.html#create-react-app
uj5u.com熱心網友回復:
為反應專案創建一個檔案夾。在終端中打開該檔案夾。(命令列)并使用npx create-react-app yourAppName. 以上錯誤與權限相關,您無權在“/usr/local/lib/node_modules/create-react-app”下創建新檔案夾。如果仍然出現此錯誤,請使用sudo npx create-react-app yourAppName.
uj5u.com熱心網友回復:
對于要全域安裝的 npm 包,主要可能會遇到權限問題。這通常可以通過在行的第一行添加sudo來解決。所以而不是:
create-react-app yourAppName
你可以這樣做:
sudo npx create-react-app yourAppName
按照您的 root 用戶密碼。
此外,要添加更多,node js 版本和 create react app 有一些報告的問題。您可以通過終端上的以下命令檢查 Mac 中安裝的節點版本:
node --version
如果安裝的Node版本是17.X,可以推測與問題有關。
始終建議使用 LTS 版本。
在此處輸入鏈接描述
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/403134.html
標籤:
