mao3
mao3

Reputation: 65

js2coffee throws cannot find module error

I have js2coffee installed globally and I tried

    js2coffee app.js > app.coffee

And I got the following error

    module.js:340
    throw err;
      ^
    Error: Cannot find module 'nopt'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/lib/node_modules/js2coffee/out/lib/command.js:16:10)
    at Object.<anonymous> (/usr/lib/node_modules/js2coffee/out/lib/command.js:273:4)
    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 Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/lib/node_modules/js2coffee/out/bin/js2coffee: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:901:3

Does anyone know how to fix this?

Upvotes: 0

Views: 505

Answers (2)

hexacyanide
hexacyanide

Reputation: 91609

It appears that the nopt module is a devDependency of js2coffee and isn't installed during production.

To fix this, navigate to js2coffee's module folder and run npm install. That will also install development dependencies, although I'm not sure why js2coffee needs them the way you're using it.

So if you're using running a Linux machine, use these commands:

cd /usr/lib/node_modules/js2coffee
npm install

Upvotes: 1

iJade
iJade

Reputation: 23791

It seems like you installed the package globally using -g option.Try installing the package like

npm install package

in the project directory

Upvotes: 0

Related Questions