Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ypapax opened this issue Nov 1, 2014 · 4 comments

Comments

@ypapax
Copy link

ypapax commented Nov 1, 2014

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.

@maxtaco
Copy link
Owner

maxtaco commented Nov 3, 2014

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
#138.

@ypapax
Copy link
Author

ypapax commented Nov 3, 2014

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.

@pdxrod
Copy link

pdxrod commented Aug 5, 2015

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
Copy link

pdxrod commented Aug 6, 2015

Got it.

CoffeeScript = require('coffee-script')

esquinas added a commit to esquinas/cloud9-coffeescript-example that referenced this issue Dec 27, 2015
As it was, this error raised:
    `Error: Use CoffeeScript.register() or require the coffee-script/register module to require .coffee.md files.`

GitHub user Maxtaco pointed out the [solution to the error here](maxtaco/coffee-script#138)
I quote 
  "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' ..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants