Alexander Shlenchack
Alexander Shlenchack

Reputation: 3869

Can't require coffee-script in the node

I have installed coffeescript and node via nvm. But I'm getting errors when I require the coffee in Node.js console:

var cs = require('coffee-script/register');
// => Error: Cannot find module 'coffee-script/register'

or

var cs = require('coffee-script');
// => Error: Cannot find module 'coffee-script'

My environment:

node -v
// => v5.0.0

coffee -v
// => CoffeeScript version 1.10.0

npm list -g coffee-script
// => ~/.nvm/versions/node/v5.0.0/lib
// => └── [email protected]

I think this problem is causing other errors like this:

knex --help
// => Failed to load external module coffee-script/register,coffee-script

Upvotes: 1

Views: 1611

Answers (4)

Wahab Hussain
Wahab Hussain

Reputation: 1

If someone still looking for legacy application. This one might help, https://www.npmjs.com/package/coffee-register.

Upvotes: 0

Evan Davis
Evan Davis

Reputation: 36592

The registered module name is coffee; just do var cs = require('coffee');

Upvotes: 0

Anonimo507
Anonimo507

Reputation: 1

export NODE_PATH=/usr/local/lib/node_modules/

This work for me

Upvotes: 0

Shanoor
Shanoor

Reputation: 13682

I guess you didn't install coffee-script locally, npm i coffee-script --save in your project's root folder.

Upvotes: 1

Related Questions