coffee-script icon indicating copy to clipboard operation
coffee-script copied to clipboard

Error: Use CoffeeScript.register() or require the coffee-script/register module to require .iced.md files

Open ypapax opened this issue 11 years ago • 4 comments

my app.js is:

 require("iced-coffee-script");
 require("./serverOneNode.iced");

when I run it:

 node app.js

got error:

          throw new Error("Use CoffeeScript.register() or require the coffee-s
                ^
Error: Use CoffeeScript.register() or require the coffee-script/register module to require .iced.md files.
  at Object._base.(anonymous function) [as .iced] (/projectPath/node_modules/iced-coffee-script/lib/coffee-script/coffee-script.js:200:17)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/projectPath/app.js:2:1)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Function.Module.runMain (module.js:497:10)
  at startup (node.js:119:16)
  at node.js:902:3

That began to happen after I updated iced-coffee-script to version 1.8.0-a and coffee-script to version 1.8.0.

ypapax avatar Nov 01 '14 11:11 ypapax

This changed a while back with [email protected]. Check the main Coffee page, and here's the explanation:

  • When requiring CoffeeScript files in Node you must now explicitly register the compiler. This can be done with require 'coffee-script/register' or CoffeeScript.register(). Also for configuration such as Mocha's, use coffee-script/register.

On Sat, Nov 1, 2014 at 7:43 AM, ypapax [email protected] wrote:

my app.js is:

require("iced-coffee-script"); require("./serverOneNode.iced");

when I run it:

node app.js

got error:

      throw new Error("Use CoffeeScript.register() or require the coffee-s
            ^

Error: Use CoffeeScript.register() or require the coffee-script/register module to require .iced.md files. at Object._base.(anonymous function) as .iced at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at Object. (/projectPath/app.js:2:1) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:902:3

That began to happen after I updated iced-coffee-script to version 1.8.0-a and coffee-script to version 1.8.0.

— Reply to this email directly or view it on GitHub https://github.com/maxtaco/coffee-script/issues/138.

maxtaco avatar Nov 03 '14 01:11 maxtaco

Thank you, @maxtaco. When I added line require('iced-coffee-script/register'); to file app.js before requiring serverOneNode.iced and so problem was solved.

ypapax avatar Nov 03 '14 01:11 ypapax

Following instructions at http://code.tutsplus.com/tutorials/better-coffeescript-testing-with-mocha--net-24696 supplemented by various stackoverflow and other pages, I did all this: npm install mocha npm install chai npm install -g coffee-script npm install iced-coffee-script

coffee -v Using CoffeeScript version 1.9.3

I have a test .coffee file containing chai = require 'chai' chai.should() expect = chai.expect require('coffee-script/register') CoffeeScript.register() ...

When I run mocha --require coffee-script/register --compilers coffee:coffee-script/register I get "CoffeeScript.register(); ^ ReferenceError: CoffeeScript is not defined"

This is also true if I miss out ' --require coffee-script/register' in the mocha line above, or if I install iced-coffee and add "require('iced-coffee-script/register')" to my test .coffee file. What am I missing?

pdxrod avatar Aug 05 '15 18:08 pdxrod

Got it.

CoffeeScript = require('coffee-script')

pdxrod avatar Aug 06 '15 17:08 pdxrod