Node.js: MODULE_NOT_LOADED using Visual Studio Code on macOS Mojave

Using the following:

  • macOS Mojave 10.14.6
  • node v12.9.0
  • Visual Studio Code 1.37.1

Created the project directory structure:

myapp
 \
  app.js

app.js:

const fs = require('fs')

fs.writeFileSync('notes.txt', 'This file was created by Node.js!')

When I try running this using Visual Studio Code's Integrated Terminal:

node app.js

Error:

internal/modules/cjs/loader.js:775
    throw err;
    ^

Error: Cannot find module '/Users/devuser/myapp/app.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
    at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

However, when I run it the same way using macOS's Terminal, it actually doesn't show an error and generates the notes.txt file with the proper contents.

This leads me to believe that there is something not configured with Visual Studio Code and node.js installed on my local system.

Am a novice to both Node.js and Visual Studio Code so any help is greatly appreciated...