Solved - You Need to Enable Javascript to Run This App

Bernard Bado - Dec 16 '21 - - Dev Community

One common error that React developers are facing is: You need to enable Javascript to run this app.

There are 3 possible solutions to solve You need to enable Javascript to run this app issue:

  • Check if you have Javascript enabled in your browser.
  • Set homepage and proxy inside package.json file.
  • Serve React app locally.

Why Does the Error Occur?

There are multiple reasons why you see You need to enable Javascript to run this app error. In the next section, we're gonna take a closer look at each one of them. And provide a solution for each reason.

How to Solve the Error

In this section, we're gonna discuss why you see You need to enable Javascript to run this app error. And provide a solution for all the possible reasons.

Solving Javascript Disabled by Browser

The most obvious solution is to check if you have Javascript enabled by the browser. After all, the error message is trying to say us that.

Here are the instructions to enable Javascript in all major browsers:

This is the most simple solution, but usually, it's not the one that works. By default, we tend to have Javascript enabled because most of the websites are using it.

If you don't have any problems browsing other websites, you'll most likely have Javascript enabled.

Solving Wrong package.json Configuration

If you're running a backend server alongside your React app, and you see the following error. There is a high chance you don't have a proxy server configured properly.

The following solution is trying to solve the issue when running the development server. If you're facing this issue only after running the production build, skip to the next section.

To fix this problem, try adding the following line inside your package.json file.

"proxy": "http://localhost:5000"
Enter fullscreen mode Exit fullscreen mode

Make sure to change port 5000 to whatever port number the server is set up to listen to.

If the proxy setup doesn't solve your problem, you can try to set up Express server yourself.

Add the following line inside package.json file.

"homepage": "."
Enter fullscreen mode Exit fullscreen mode

And follow up with changes to index.js file.

app.use(express.static(__dirname));

app.get("/*", function(req, res) {
  res.sendFile(path.join(__dirname, "index.html"));
});
Enter fullscreen mode Exit fullscreen mode

Solving Production Build Issues

If you're not having any problems when running your React app in the development server, but you see the You need to enable Javascript to run this app error when you run production build. You probably need to set up a server to serve your React app correctly.

We have an in-depth guide covering this topic. Follow the link on How to Run React Build Locally.

To serve a production build, you need to install a package called serve. And use it to serve a production build.

In your terminal, run the following command.

npm install -g serve
# Or if you're using Yarn
yarn global add serve
Enter fullscreen mode Exit fullscreen mode

All that's left to do is tell serve package which folder you want to serve. Assuming you're inside your project directory. You'd run a command like this.

serve build
Enter fullscreen mode Exit fullscreen mode

Concluding Thoughts

You need to enable Javascript to run this app is a common error for React applications. And in times, it can also be a confusing one.

In this article, we covered the reasons you see You need to enable Javascript to run this app error in your React app. And we also provided multiple solutions on how to handle this error.

Next time you're facing this error, you should know exactly how to troubleshoot it properly. And how to fix this error in your React project.

. . . . . . . . . . . . . . . . . . . . . . . . . . .