2014-04-29 75 views
0

我正在嘗試關注CoffeScript的tutorial我如何需要一個CoffeeScript文件?

我打開終端,導航到的目錄中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爲好,而不./

+1

您是否看了NodeJS文檔,查看http://nodejs.org/api/modules.html – elclanrs

+0

當然您需要將您的咖啡編譯爲js,然後才能在NODE.js中使用它;-) – andi

+0

嘗試開始'coffee' repl而不是'node' – Bergi

回答

相關問題