无法在mac上运行带有node.js的js文件

时间:2014-06-07 05:31:01

标签: javascript node.js macos

我是node.js和javascript的新手。我成功安装了node.js,但是当我在mac上的终端上运行js文件时,我收到了错误。

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

我确定example.js位于/ Users / cuibosoft /。我不知道为什么节点可以。

1 个答案:

答案 0 :(得分:0)

您可能认为是这样,但从您的评论来看,example.js不能在/Users/cuibosoft中。如果它在您的桌面上,那么它真的在/Users/cuibosoft/Desktop。如果要将其正确移动到主目录,可以按⌘⇧H在Finder中打开主目录。