1、首先安装react脚手架
npm install -g create-react-app
2、创建react项目
create-react-app my-app
3、
PS D:\桌面\papers\subject> create-react-app my-react-appCreating a new React app in D:\桌面\papers\subject\my-react-app.Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...added 1479 packages in 27s252 packages are looking for fundingrun `npm fund` for detailsInitialized a git repository.Installing template dependencies using npm...
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@testing-library/dom@10.4.0',
npm WARN EBADENGINE required: { node: '>=18' },
npm WARN EBADENGINE current: { node: 'v16.17.0', npm: '8.15.0' }
npm WARN EBADENGINE }added 63 packages, and changed 1 package in 6s252 packages are looking for fundingrun `npm fund` for details
Removing template package using npm...npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@testing-library/dom@10.4.0',
npm WARN EBADENGINE required: { node: '>=18' },
npm WARN EBADENGINE current: { node: 'v16.17.0', npm: '8.15.0' }
npm WARN EBADENGINE }removed 1 package in 1s252 packages are looking for fundingrun `npm fund` for detailsCreated git commit.Success! Created my-react-app at D:\桌面\papers\subject\my-react-app
Inside that directory, you can run several commands:npm startStarts the development server.npm run buildnpm testStarts the test runner.npm run eject
Compiled successfully!```3、根据提示进入项目目录```javascript
cd my-react-app
4、启动项目
npm run start
5、浏览器中出现react图标项目就创建成功并运行了