Home > Software design >  Not able to run node in the terminal
Not able to run node in the terminal

Time:08-07

I opened the terminal on my mac, and first checked that I have node installed: node -v v14.17.5

I then tried to open a file I created index.html from Visual Studio Code and I got a throw err from the terminal. { The code:'Module_NOT_FOUND', requireStack:[] }

Thank you in advance for help.

CodePudding user response:

node is a runtime environment that can execute javascript on a machine. So it can't read html file, but only js files. You can execute a js file with the following command in the terminal: node index.js

Et voilà.

Please note you can also write javascript directly in your terminal by entering a node environment.

node
const a = "hello"
a

// return "hello"

CodePudding user response:

I think you are trying to run an html file using node
just change the index.html to index.js

  • Related