How to run javascript scripts from within VS Code using F5 or CTRL + F5?

318 Views Asked by At

When I try to run any javascript file from VS Code using native VS Code options: either 'Start debugging (F5)' or 'Run without debugging (CTRL + F5)', I get the following error:

Process exited with code 1
Uncaught Error Error: Cannot find module '/home/altair/Documents/Desktop/test/hello_world.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Module._load (node:internal/modules/cjs/loader:778:27)
    at executeUserEntryPoint (node:internal/modules/run_main:77:12)
    at <anonymous> (node:internal/main/run_main_module:17:47)

Where /home/altair/Documents/Desktop/test/hello_world.js is the path to file that I am trying to run.

I can run JS scripts fine from the terminal (including the terminal opened inside VS Code) with node ./hello_world.js, so the problem must be somewhere in VS Code.

Is it possible to run JS scripts from within VS Code using F5 or CTRL + F5?

0

There are 0 best solutions below