我试图创建一个 React 应用程序,但是当我拥有节点版本 9.7.2 和 npm 版本 6.4.1 时,它给我带来了错误

I tried to create a react app but it is givinig me errors when I had the node version 9.7.2 and npm version 6.4.1

在 /home/sunidhi/Documents/major 中创建一个新的 React 应用程序。

Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts...

yarn add v1.7.0 [1/4] Resolving packages... [2/4] Fetching packages... error eslint@5.6.0: The engine "node" is incompatible with this module. Expected version "^6.14.0 || ^8.10.0 || >=9.10.0". error Found incompatible module info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation. yarnpkg add --exact react react-dom react-scripts --cwd /home/sunidhi/Documents/major has failed.

Deleting generated file... package.json Deleting generated file... yarn.lock Deleting major/ from /home/sunidhi/Documents Done.

最好的方法是使用 nvm(节点版本管理器)安装节点。

  1. 按照网页上的说明安装 nvm。

  2. 使用 nvm 安装节点。

  3. 安装 npm。

  4. 然后担心 React 并通过 npm 安装它。

install nvm