ReactJS-logoReactJS-logo在CentOS 8上安装ReactJS

步骤1.首先,让我们首先确保您的系统是最新的。

sudo dnf clean all
sudo dnf update
sudo dnf install gcc-c++ make

步骤2.安装Node Version Manager和Node.js。

现在,我们在CentOS系统上添加Node.js存储库:

curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash –

然后,使用以下命令安装Node.js:

sudo dnf install nodejs

验证您安装的Node.js版本:

$ node -v
$ npm -v

步骤3.安装ReactJS软件包。

运行以下命令以安装ReactJS软件包:

npm install -g create-react-app

步骤4.创建一个示例React App。

您可以使用以下命令之一创建React.js应用程序:

create-react-app myreactjsapp

您将在屏幕上看到长结果:

Success! Created myreactjsapp at /opt/myreactjsapp
Inside that directory, you can run several commands:

  npm start
    Starts the development server.

  npm run build
    Bundles the app into static files for production.

  npm test
    Starts the test runner.

  npm run eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd myreactjsapp
  npm start

一旦创建了React应用程序。这将在当前目录中使用项目名称创建一个文件夹。切换到该项目并运行npm start以启动应用程序:

cd myreactjsapp
npm start

恭喜你!您已经成功安装了ReactJS。感谢您使用本教程在CentOS 8系统上安装ReactJS。如需更多帮助或有用信息,建议您访问ReactJS官方网站。