Help with Nodejs command line issues

Please, I need help accessing Nodejs from the command line. Anytime I try to initiate a command on the command line, I am directed back to my Editor. I can’t even check the Version of Node using the following command { Node --version}

My path variable is as follows : C:\Program Files\ nodejs


Need more information here, could you maybe post some screenshots, exactly what is the issue? I assume it’s windows?

  1. I created a folder from the command line (Nodejs)
  2. I opened the Folder(Nodejs) on the visual studio code editor
  3. I created a new file inside the folder(nodevoyage.js)
  4. I added a few lines of code
  5. I tried to run it on the command line … {node nodevoyage.js}

Now here is the issue: any time I get to step 5, the code doesn’t run but redirects me back to a blank file (node.js) that appears on my editor. Please refer to the screenshots. I really want to know what i am doing wrong. Thanks!

And yes, I am making use of Windows (8.1)

Been a while since I ran node.
cd to your directory of choice,

 npm init

in said folder to create a package.json file.

Then the easiest way is to use express,

npm install express --save

Then you can create a server.js file and add

const express = require('express')
const app = express();

app.get('/', (req, res) => {
  res.send('Hello World!')

app.listen(8000, () => {
  console.log('Example app listening on port 8000!')

Then run the program by writing

node server.js

Then in your browser go to
localhost:8000 to see the response

You don’t need to initialize npm to run a simple js file with node , @2virtual seems to be doing correctly, what I think is that there is some type of corruption with his node installation, node -v should always give you the correct node version installed, I suggest a complete uninstall and reinstall of the Lts version downloaded directly from the node website, and follow the instructions for windows should be straightforward, never had such a problem with several installations on windows 10.