之前创建react的项目是直接在终端(安装好node之后)使用命令create-react-app my-app
,但现在已经不再支持这个命令,如果还使用这个命令的话,在生成的package.json文件中会缺少script导致后续的npm start命令出错。
如今创建项目是在某目录下使用命令npx create-react-app my-app
来创建,后续命令还是一样。
Installing create-react-app globally is now discouraged. Instead uninstall globally installed create-react-app package by doing: npm uninstall -g create-react-app
(you may have to manually delete package folder if this command didn’t work for you. Some users have reported they had to delete folders manually)
Then you can run npx create-react-app my-app
to create react app again.
ref: https://github.com/facebook/create-react-app/issues/8086
npm create vite@latest xxx 使用vite创建react或者vue项目
npx create-react-app xxx 创建名字为xxx的项目文件夹