This JavaScript error occurs when Discord is not able to access installation files leading to the process being hindered completely.
One reason for this is a case of Discord or its settings being corrupt.
How To Fix A JavaScript Error In Discord
Delete Discord Folders
Doing this should reset Discord settings hopefully clearing the error.
Open Windows Explorer and click on This PC. Type in C:\Users\YOURUSERNAME\AppData\Discord.
In the File explorer’s menu, click on the View tab and then check the box next to Hidden items.
In the App Data folder, delete the Discord folder and then open Run dialog box.
Type in %localappdata% then press Enter. In the folder that opens, right click on the Discord folder then opt for Delete.
Change The Status Type Of The Quality Windows Audio Video Experience Service
Change the status form Manual to Automatic and you should be able to start up Discord without any problems.
Press Windows + R to open the Run dialog box and type in services.mc then click OK.
In the list that opens, locate the Quality Windows Audio Video Experience service and right click on it.
A Context menu will appear, click on Properties. If the service status says Started, click on the Stop option.
Under Startup type, click on Automatic and the error should not crop up again.
Do Not Run Discord As Administrator
This is because, this error tends to occur mostly when the program is being run with administrator privileges.
Administrator permissions are usually the problem.
Right click on Discord and choose Properties. In the Compatibility tab, uncheck the box next to Run this program as an administrator.
Click on OK and now the program will run without administrator privileges so the error should not occur.
Reinstall Discord
However common this step looks like, it has been proven to be very effective in clearing this error.
To reinstall, you have to be logged in as an administrator. Open the Control panel from the search box and change the View as type to Category.
In the Programs section, click on Uninstall a program. A list of programs will be displayed, right click on Discord and click on the Uninstall option.
Click Yes when asked, Completely remove Discord from this computer then click on Finish once the program is completely uninstalled.
Now, from Discord’s website, get the latest version of the program, download and install it.
Close All Discord Processes
If after all the above steps have been taken and you still have no luck with the error, you can try using the task manager to end all Discord processes then install the program once again.
Open the Run dialog box and type taskmgr then hit Enter. Once open, search for All Discord processes, click on it and choose the End Process option.
Installation of Discord should now take place without any hitches.