无法创建 WebStorm React 项目

Can't create WebStorm React project

我正在尝试在 WebStorm 2016.3.1 中创建一个 React 项目

它要求我提供 create-react-app 但我不知道那是什么,而且我在 Google 上找不到任何参考资料。

它是什么,我在哪里可以找到它的值?

在使用此功能之前,您需要安装 create-react-app npm 模块。

npm install -g create-react-app

您可以在 official release blog of WebStorm 上阅读有关此功能的更多信息。

文档摘录:

Make sure that you have create-react-app installed globally on your computer, for that run npm install -g create-react-app. Then to start your new project, double click on the start task in the npm tasks tool window to run it. That’s it!

我已经使用 yarn 全局安装了 ie create-react-app,但 webstorm 找不到它。然后我使用 npm,更不用说 globally,它的工作就像一个魅力。

我按照以下步骤创建了 webStrom React 应用程序。

  1. Download node.js
  2. Open command line console and type "npm install -g create-react-app"
  3. Create react app project from web-storm.
  4. Make sure you provided the correct file path of create-react-app , by default it is installed in ~\AppData\Roaming\npm\node_modules\create-react-app

使用 npm start:启动开发服务器

TL;DR
No need to install anything. Just enter npx create-react-app in the create-react-app field & it should work like a pycharm, I mean charm :)

旁注:自 npm 版本 5.2.0 以来,npx 已与 npm 预捆绑。

如果您使用 asdf 或任何其他工具来管理多个版本的 nodejs,您将需要手动设置 create-react-app 的路径

我在 mac,所以对我来说路径是

/Users/<USER>/.asdf/installs/nodejs/12.16.2/.npm/lib/node_modules/create-react-app