【发布时间】:2014-06-15 01:17:02
【问题描述】:
我正在尝试关注 tutorial 获取 CoffeScript。
我打开终端,导航到存在simpleMath.coffee 的目录并运行node 并尝试var SimpleMath = require('./simpleMath');,这会导致以下错误:
Error: Cannot find module 'simpleMath'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at repl:1:18
at REPLServer.self.eval (repl.js:110:21)
at repl.js:249:20
at REPLServer.self.eval (repl.js:122:7)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
我也试过simpleMath,没有./。
【问题讨论】:
-
你看过 NodeJS 文档吗,见nodejs.org/api/modules.html
-
当然你需要把你的coffee编译成js才能在NODE.js中使用;-)
-
尝试启动
coffeerepl 而不是node
标签: javascript node.js coffeescript