I installed nodejs in C:\\Program Files (x86)\\nodejs
then I created a .js file and saved it in my desktop just to output \'hello world\' in the console:
Try npm install --production
and then npm start
.
While i tried to run my first node application i had encountered the same issue but when i tried to see what the issue might be it was the path of the file. I was running the node .js from different location and hence encountered the issue. When i fixed the path this worked fine.
If you are using a framework like express, you need to put the package.json file into the folder you are using and don't forget change main name.
Make sure you saved the file as JavaScript. Un check 'Hide extensions for all known type' check box in Folder Options window will show you the correct file extension(Folder>>view>>Option).
Try typing this into the Node command-line environment:
.load c:/users/laura/desktop/nodeTest.js
.
It should work for what you're trying to do.
If you want to call the file directly, you'd have to have it in the root directory where your Node installation resides.
Easy way for this problem
npm link e