【问题标题】:How can I require a CoffeeScript file?如何需要 CoffeeScript 文件?
【发布时间】: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,没有./

【问题讨论】:

标签: javascript node.js coffeescript


【解决方案1】:

你需要先把你的咖啡编译成js。请参阅https://github.com/oklai/koala 它在 GUI 中捕获并编译您的文件 - 并在失败时发送通知。真的很好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-20
    • 2011-10-13
    • 1970-01-01
    • 1970-01-01
    • 2015-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多