How to fix “A JavaScript error occured in the main process” (VSCode, Discord, …)
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
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.
- Open the Task Manager (CTRL+Shift+Esc) and search for all processes of your programme and end them with a right-click.
- Then press your Windows key + R to open the “Run” window and type “%appdata%” there.
- Search for the “discord” folder there and delete it.
- Repeat the process by entering “%LocalAppData%” and delete the “Discord” folder there too.
- Now restart your PC.
- 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:
- Download the latest Microsoft Visual C++ installer here. In most cases, the installer on the screenshot will be the right one for you:
- Open the installer and click on “Repair”.
- Restart your PC now.
- 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:
This should hopefully solve the problem once and for all!
What did you think of this post?