简体   繁体   English

我如何需要CoffeeScript文件?

[英]How can I require a CoffeeScript file?

I am trying to follow this tutorial for CoffeScript. 我正在尝试遵循CoffeScript的本教程

I open the terminal, navigate to the directory where simpleMath.coffee is present and run node and try var SimpleMath = require('./simpleMath'); 我打开终端,导航到存在simpleMath.coffee的目录并运行node然后尝试var SimpleMath = require('./simpleMath'); , which results in the following error: ,导致以下错误:

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)

I tried simpleMath as well, without ./ . 我也尝试过simpleMath ,没有./

You need to compile your coffeee into js first. 您需要先将coffeee编译成js。 See https://github.com/oklai/koala it catches and compile your files in a GUI - and send notifications when it fails. 请参阅https://github.com/oklai/koala,它捕获并在GUI中编译文件-并在失败时发送通知。 Really good. 真的很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM