Vijay Reddy Vijay Reddy - 1 year ago 92
Node.js Question

cannot find module is the error if i try node hello.js

I am trying this command to run my js file to check whether node is installed properly or not.. 'C:\Users\vijay reddy\hello.js' but getting this error

Error: Cannot find module 'C:\Users\vijay reddy\hello.js'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3

Answer Source

if you create a file hello.js like so:

console.log('Hello World!');

And you are in the directory it exists in, and run (from your command prompt):

node hello.js

You will get the correct output if node is installed correctly.

To figure out why it's not, try the other commands they suggest. If you try:

node -v

and you get nothing, or an error, then that means either Node isn't installed, or it's not in your current users %PATH%.

Also, depending on how you created hello.js, Windows may have "helpfully" changed it to hello.js.txt for you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download