【发布时间】:2022-01-18 16:13:39
【问题描述】:
我正在尝试创建一个新的 react 应用程序,但我似乎做不到。我到处搜索,尽我所能,无能为力。我已经删除了 node、npm 和 npx 两次并再次下载,然后重新启动计算机 100 次,但没有任何效果:
Need to install the following packages:
create-react-app
Ok to proceed? (y)
You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
my@mycomp-MacBook-Pro ~ % npm uninstall -g create-react-app
up to date, audited 1 package in 176ms
found 0 vulnerabilities
my@mycomp-MacBook-Pro ~ % npx create-react-app my-app
Need to install the following packages:
create-react-app
Ok to proceed? (y)
You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
my@mycomp-MacBook-Pro ~ %
然后,如果我尝试 npm uninstall -g create-react-app 或其他任何东西,它总是会发送此错误:
my@mycomp-MacBook-Pro ~ % npm uninstall npm uninstall -g create-react-app
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/npm',
npm ERR! dest: '/usr/local/lib/node_modules/.npm-i9nnxROI'
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/mycomp/.npm/_logs/2021-12-15T12_37_53_679Z-debug.log
my@mycomp-MacBook-Pro ~ %
我该如何解决这个问题?
【问题讨论】:
-
这个命令能解决你的问题吗?
sudo npm uninstall -g create-react-app -
我也遇到了同样的情况。它看起来应用程序已更新,并迫使您更新。我按说卸载并使用“npx create-react-app my-app”再次安装。
标签: reactjs terminal create-react-app