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?
It sounds like
requireisn’t looking in npm’s global install path. Runfrom the Node REPL to see which paths are being looked in. On the command line, run
to see the directory that
npmis installing global libraries in (it’s/usr/local/libon my Mac). Add/node_modulesto that, and add it torequire.paths. You can do this on a one-time basis by running(Update: Modifying
require.pathsis no longer allowed as of Node 0.5+.)or you can do it permanently by adding the line
to your
~/.bashrcfile.