安装 React js 的区别和最佳方式是什么? npm install -g create-react-app 或 npx create-react-app name-project ?
我在blos和react文档中搜索但没有得到任何答案,我想要一个更具体的答案
首先,create-react-app 已被弃用,所以你可能应该使用类似 Vite 的东西。
其次,这两个命令都不是严格安装react的。如果您只想安装它,请在您的目录中运行
npm i react react-dom
。如果你决定使用 create-react-app,正确的 run 方法是使用 npx create-react-app project-name
,因为你的另一个命令 (npm install -g create-react-app
) 只是全局安装 create-react-app 而不运行任何东西。