我已經嘗試安裝命令npm install -g create-react-app
但我收到這樣的錯誤
Ahamad@MacBooks-MacBook-Pro ~ % node -v
v16.15.0
Ahamad@MacBooks-MacBook-Pro ~ % npm -v
8.5.5
Ahamad@MacBooks-MacBook-Pro ~ % npm install -g create-react-app
npm ERR! code EACCES
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/Ahamad/.npm/_logs/2022-05-15T16_46_06_712Z-debug-0.log
Ahamad@MacBooks-MacBook-Pro ~ %
uj5u.com熱心網友回復:
您是否嘗試在命令前添加 sudo ?
sudo npm install -g create-react-app
uj5u.com熱心網友回復:
首先運行此命令以糾正 /usr/local 下的檔案所有權:
sudo chown -R $(id -un):$(id -gn) /usr/local/*
然后重新運行你npm install...
uj5u.com熱心網友回復:
你為什么要安裝這個?
如果您安裝了 npm 和 node,您只需在要創建專案的檔案夾中運行以下命令。
注意一開始是 NPX 而不是 NPM,這不是錯誤
npx create-react-app <your app name here>
有關更多資訊,請參閱React 檔案
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/475013.html
下一篇:狀態改變渲染前一個狀態React
