Reputation: 9487
I'm trying to get the functionality of CoffeeScript.compile in node.js.
I've installed node on Cygwin in Windows, and installed coffee script with npm.
I can use the coffee command fine but if I try to
require("coffee-script");
I get "Cannot find module 'coffee-script'" in node.
Am I going about this the wrong way?
Upvotes: 2
Views: 3058
Reputation: 77416
It sounds like require
isn't looking in npm's global install path. Run
require.paths
from the Node REPL to see which paths are being looked in. On the command line, run
npm ls -g
to see the directory that npm
is installing global libraries in (it's /usr/local/lib
on my Mac). Add /node_modules
to that, and add it to require.paths
. You can do this on a one-time basis by running
require.paths.shift('/usr/local/lib/node_modules');
(Update: Modifying require.paths
is no longer allowed as of Node 0.5+.)
or you can do it permanently by adding the line
export NODE_PATH=/usr/local/lib/node_modules
to your ~/.bashrc
file.
Upvotes: 9
Reputation: 22105
Are you using from a different directory? If so, install it globally with the -g flag. (npm install coffee-script -g).
Upvotes: 1