0

I am trying to follow this tutorial for CoffeScript.

I open the terminal, navigate to the directory where simpleMath.coffee is present and run node and try 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 ./.

Louis
  • 146,715
  • 28
  • 274
  • 320
andilabs
  • 22,159
  • 14
  • 114
  • 151
  • 1
    Have you looked at the NodeJS docs, see http://nodejs.org/api/modules.html – elclanrs Apr 29 '14 at 08:04
  • of course you need to compile your coffee to js before you can use it in NODE.js ;-) – andilabs Apr 29 '14 at 08:09
  • try to start the `coffee` repl instead of `node` – Bergi Apr 29 '14 at 09:23
  • possible duplicate of [require()'ing a CoffeeScript file from a JavaScript file or REPL](http://stackoverflow.com/questions/4768748/requireing-a-coffeescript-file-from-a-javascript-file-or-repl) – Louis Apr 29 '14 at 09:48

1 Answers1

0

You need to compile your coffeee into js first. See https://github.com/oklai/koala it catches and compile your files in a GUI - and send notifications when it fails. Really good.

Vinz243
  • 9,654
  • 10
  • 42
  • 86