Windows Script Host Error 800A03EA on Express.js code

I am learning JavaScript development and the book I'm following (JavaScript Everywhere) tells me run this code:

const express = require('express');
const app = express();
app.get('/', (req, res) => res.send('Hello World'));
app.listen(4000, () => console.log('Listening on port 4000!'));

I understand what this code is supposed to do but when I try to run it using src/index.js in the terminal, it always gives me this error: Syntax Error 800A03EA Microsoft JScript compilation error

I have tried all fixes I found on the internet but I'm guessing this has something to do with the fact that this isn't regular JS syntax, it's Express JS and somehow Express JS is not enabled? I've checked the basics including:

  1. node --version (returns v12.14.0)
  2. npm --version (returns 6.13.4)
  3. npm install express --save just in case there was some problem with ExpressJS API

Windows 10 Laptop, using VSCode. Please ask for any information you need.


Solution 1:

Run it using node src/index.js.

By using just src/index.js you are using the default handler for JS files on Windows which is Windows Script Host (and not Node.js).