Test Javascript on vscode

Viewed 52

I am learning JavaScript and I want to test my code on vscode, for example:

var guestList = ["Angela", "Jack", "Pam", "James", "Lara", "Jason"];
var guestName = prompt("What is your name?");

if (guestList.includes(guestName)) {
    alert("Welcome!");
} else {
    alert("Sorry, maybe next time.");
}

I have installed nodejs but when trying to run the program it gives me an error:

PS C:\Users\aleja\Documents\MEGA\Learning\Udemy\The Complete 2022 Web Development Bootcamp> node Arrays.js
node:internal/modules/cjs/loader:959
  throw err;
  ^

Error: Cannot find module 'C:\Users\aleja\Documents\MEGA\Learning\Udemy\The Complete 2022 Web Development Bootcamp\Arrays.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

The file is in this Folder: enter image description here

var guestList = ["Angela", "Jack", "Pam", "James", "Lara", "Jason"];
var guestName = console.log("What is your name?");
if (guestList.includes(guestName)) {
    console.log("Welcome!");
} else {
    console.log("Sorry, maybe next time.");
}

Yes the file is on the folder: enter image description here

I think the issue is on the directory I am looking into, I was looking into the previous folder. I cd the right directory: PS C:\Users\aleja> cd "Documents\MEGA\Learning\Udemy\The Complete 2022 Web Development Bootcamp\Section10_Intermediate Javascript"

And now I don't get the error.

0 Answers
Related