How to fix “A JavaScript error occured in the main process” (VSCode, Discord, …)

javascript-error

Are you getting the error message “A JavaScript error occured in the main process” or similar? This happens occasionally when opening VSCode, Discord or other apps. How to fix the problem!

The error message “A JavaScript error occurred in the main process” or something similar occurs frequently under Windows 10.

A JavaScript error occured in the main process
A JavaScript error occured in the main process

A JavaScript error occured in the main process

Uncaught Exception:
Error: Cannot find module ‘…’

The problem can occur with various programmes, e.g.

  • Visual Studio Code
  • Discord
  • Microsoft Teams
  • Valorant

There are several things you can try to fix the JavaScript error. Just try your way through the list, the easiest and quickest comes at the beginning.

Method 1: Delete temporary data

This method only works for Discord. If you have the JavaScript error in another programme, jump directly to the 2nd method.

To delete the temporary data, you should first end all processes.

  1. Open the Task Manager (CTRL+Shift+Esc) and search for all processes of your programme and end them with a right-click.
Task Manager: End processes
Task Manager: End processes
  1. Then press your Windows key + R to open the “Run” window and type “%appdata%” there.
Windows + R: %appdata%
Windows + R: %appdata%
  1. Search for the “discord” folder there and delete it.
  2. Repeat the process by entering “%LocalAppData%” and delete the “Discord” folder there too.
  3. Now restart your PC.
  4. Try to open Discord.

Method 2: Repair or reinstall Microsoft Visual C++ installation

In some cases, the installation of Microsoft Visual C++ is defective. We can then repair the installation as follows:

  1. Download the latest Microsoft Visual C++ installer here. In most cases, the installer on the screenshot will be the right one for you:
Find the right Microsoft Visual C++ installer
Find the right Microsoft Visual C++ installer
  1. Open the installer and click on “Repair”.
Microsoft Visual C++ Redistributable Installer
Microsoft Visual C++ Redistributable Installer
  1. Restart your PC now.
  2. Try to open the affected programme.

Method 3: Reinstall the affected programme

Sometimes a simple reinstallation of the programme helps. As a first step, you can try to simply install it “over”. If this does not work, you can first uninstall the programme and then reinstall it.

When reinstalling, your data in Visual Studio Code and Discord will be retained (tested). For all other programs under Windows 10 and Windows 11, the data may be lost.

Download the latest installer from the website and run it:

You can simply confirm messages like this:

Installation already available - continue?
Installation already available – continue?

This should hopefully solve the problem once and for all!

Related Posts
Leave a comment

Your email address will not be published. Required fields are marked *

bold italic underline strikeThrough
insertOrderedList insertUnorderedList outdent indent
removeFormat
createLink unlink
code

This can also interest you