简体   繁体   English

无法在WebStorm中创建React.js项目

[英]Unable to create React.js project in WebStorm

I am going to create a React.js web application in WebStorm. 我将在WebStorm中创建一个React.js Web应用程序。 I have installed create-react-app in /usr/local/bin and Node.js interpreter. 我已经在/usr/local/bin和Node.js解释器中安装了create-react-app I use Debian sid Linux distribution. 我使用Debian sid Linux发行版。 When I try create project in WebStorm I receive this error: 当我尝试在WebStorm中创建项目时,出现以下错误:

/usr/bin/node /usr/local/bin/index.js .
module.js:538
    throw err;
    ^

Error: Cannot find module '/usr/local/bin/index.js'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3
Done

I hope for help. 希望对您有所帮助。

Try installing both node and create-reat-app globally by using -g flag in npm and make sure both are available system wide. 尝试通过在npm中使用-g标志来全局安装两个节点和create-reat-app,并确保两者在系统范围内都可用。 To make node-interpreter available globally try setting default in nvm or try installing nodejs-legacy. 要使节点解释器全局可用,请尝试在nvm中设置default或尝试安装nodejs-legacy。

Anyways Web storm provides coding assistance depending on the file extension. 无论如何,Webstorm根据文件扩展名提供编码帮助。 Such as if it is a .jsx file then auto completion helps you in writing react specific syntax and enhanced ES syntax. 例如,如果它是一个.jsx文件,则自动完成功能可帮助您编写特定的语法和增强的ES语法。

Also even after creating the project via Webstorm you have to install dependencies though npm install. 同样,即使在通过Webstorm创建项目后,也必须通过npm install安装依赖项。

So my suggestion is instead of getting stuck just create a project using only create-react-app from the console by typing create-react-app and then everything will be set for you. 因此,我的建议是不要陷入困境,而只是通过在控制台中键入create-react-app使用仅create-react-app创建一个项目,然后为您进行所有设置。 Test the set up by going inside the project folder and running npm start you could see basic react app open in your browser. 通过进入项目文件夹并运行npm start来测试设置,您可以在浏览器中看到基本的react app打开。

For further coding you can open your project folder inside web storm and continue with your project 要进行进一步的编码,您可以在webstorm中打开项目文件夹,然后继续进行项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM