我在控制台中收到错误“您需要启用 JavaScript 才能运行此应用程序。” 反应
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/50286927/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I am getting error in console "You need to enable JavaScript to run this app." reactjs
提问by Jagdeesh Kumar
I am new to reactjs, I am working on a app. It was running fine, but when I've run npm run build command, I am getting error "You need to enable JavaScript to run this app.". I have made changes in server.js file even I've given "homepage": "./", but it did not solved my issue.
我是 reactjs 的新手,我正在开发一个应用程序。它运行良好,但是当我运行 npm run build 命令时,出现错误“您需要启用 JavaScript 才能运行此应用程序。”。即使我给出了“主页”:“./”,我也对 server.js 文件进行了更改,但它并没有解决我的问题。
And I've checked by running laravel project, javascript is enabled in browser, also tried different browsers.
我通过运行 laravel 项目进行了检查,浏览器中启用了 javascript,还尝试了不同的浏览器。
Someone please help me to overcome this error.
有人请帮助我克服这个错误。
Thanks in advance.
提前致谢。
回答by Denys Bushulyak
I had same problem. My workable solution:
我有同样的问题。我可行的解决方案:
package.json:
包.json:
"homepage": "."
index.js:
索引.js:
app.use(express.static(__dirname)); //here is important thing - no static directory, because all static :)
app.get("/*", function(req, res) {
  res.sendFile(path.join(__dirname, "index.html"));
});
回答by MaxWidth
I received this message when no proxy to the server was specified inside client package.json file.
我在客户端 package.json 文件中未指定服务器代理时收到此消息。
"proxy": "http://localhost:5000"
(where 5000 should be changed to whatever port number the server was setup to listen to. In my case it also required server restart once added)
(其中 5000 应更改为服务器设置为侦听的任何端口号。在我的情况下,添加后还需要重新启动服务器)
回答by Paulo Cuellas
I had the same problem. In my case, the class name wasn't following the patterns (must starts with uppercase). As soon as I corrected it everything started to work well.
我有同样的问题。就我而言,类名没有遵循模式(必须以大写开头)。一旦我纠正了它,一切都开始运作良好。
回答by Philipedia
Go to your SignIn component or Register component, change the form tag to a div tag OR prevent the form default i.e (e.preventDefault). Also make sure that Javascriptis enabled in your browser.
转到您的登录组件或注册组件,将表单标签更改为 div 标签或阻止表单默认值,即(e.preventDefault)。还要确保在您的浏览器中启用了Javascript。
回答by skedwards88
Also a react newbie, I hit this issue. Remembering to add ReactDOM.render(<MyClassName />, document.getElementById("root"));fixed it for me.
也是一个反应新手,我遇到了这个问题。记得ReactDOM.render(<MyClassName />, document.getElementById("root"));为我添加修复它。
回答by LeoLozes
I had some cookies set in the same url (localhost:8080), probably from a previous development, and it was somehow messing with my React project. I only found out because (out of despair) I tried with another browser and it worked. I deleted the cookies and it worked perfectly.
我在同一个 url (localhost:8080) 中设置了一些 cookie,可能来自之前的开发,它以某种方式干扰了我的 React 项目。我才发现是因为(出于绝望)我尝试了另一个浏览器并且它有效。我删除了 cookie,它运行良好。
回答by PranavPinarayi
in chrome goto chrome://settings/content/javascript and enable javascript
在 chrome 中转到 chrome://settings/content/javascript 并启用 javascript

