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.
How can I require a CoffeeScript file?
-
11-07-2023 - |
Question
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 ./
.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow