【问题标题】:Error with terminal when trying to create-react-app尝试创建反应应用程序时终端出错
【发布时间】: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


【解决方案1】:

首先,移除包裹。如果你已经使用 npm 安装了 create-react 包,那么使用

- npm uninstall -g create-react-app

或者如果纱线

- yarn global remove create-react-app

然后就可以创建项目了:

npx create-react-app my-app

【讨论】:

    【解决方案2】:

    问题似乎是安装不当。解决此问题的首选方法是确保正确卸载 nodenpm。请按照提到的步骤here。正确卸载后,前往install node 并继续重新安装。

    【讨论】:

      猜你喜欢
      • 2021-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 2020-12-23
      • 1970-01-01
      • 2021-06-01
      • 2020-09-15
      相关资源
      最近更新 更多