Han Pengbo
Han Pengbo

Reputation: 1436

Can't run js file with node.js on mac

I'm new to node.js and javascript. I install node.js successfully,but when I run the js file in terminal on mac,I got error.

han:~ cuibosoft$ node example.js 

module.js:340
    throw err;
          ^
Error: Cannot find module '/Users/cuibosoft/example.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

I'm sure example.js is at /Users/cuibosoft/. I don't know why node can't it.

Upvotes: 1

Views: 6000

Answers (1)

icktoofay
icktoofay

Reputation: 129119

You might think it is, but judging from your comment, example.js cannot be in /Users/cuibosoft. If it's on your desktop, then it's really in /Users/cuibosoft/Desktop. If you want to move it to your home directory proper, you can open your home directory in Finder by pressing ⌘⇧H.

Upvotes: 1

Related Questions