yeoman / generator-angular

Yeoman generator for AngularJS
http://yeoman.io
5.73k stars 1.44k forks source link

module.js:341 throw err - Error: Cannot find module './lib/env' #1252

Open ghost opened 8 years ago

ghost commented 8 years ago

Not sure this is the fault of the generator, but other generators do work. Whenever I am running yo angular I'm getting this:

module.js:341 throw err; ^

Error: Cannot find module './lib/env' at Function.Module._resolveFilename (module.js:339:15) at Function.Module._load (module.js:290:25) at Module.require (module.js:367:17) at require (internal/module.js:16:19) at Object. (/opt/local/lib/node_modules/generator-angular/node_modules/yeoman-generator/main.js:8:19) at Module._compile (module.js:413:34) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Module.require (module.js:367:17)

Version Data:

I tried running this and didn't have any luck:

sudo npm cache clean && \
  sudo npm install -gf yo && \
  sudo npm install -gf generator-angular
isaacerd commented 8 years ago

set NODE_PATH=C:\Users\MyUser\node_modules This is the soluction

ghost commented 8 years ago

That worked. On my mac I just added this in my .bash_profile: export NODE_PATH="/usr/local/lib/node_modules"

isaacerd commented 8 years ago

The Comant Is success??

rakeshmishrait commented 8 years ago

I have also this problem in windows -7

cordova create hello com.example.hello HelloWord Module.js:341

Cannot find Module ?

how to install the module and which module is need there?

c29130811 commented 8 years ago

I have to same problem in mac. I try to "export NODE_PATH="/usr/local/lib/node_modules" add in .bash_profile but the problem is not resolved.

medianetix commented 8 years ago

Same problem under Ubuntu 14.04. This worked for me:

nano ~/.bashrc add the export line which was /usr/lib/node_modules in my case: export NODE_PATH="/usr/lib/node_modules"

Save the file, close the console and open a new console. Retry - should work now.

Karbophos commented 8 years ago

Thanks pals, setting up environment variable on Win7 helped! NODE_PATH=c:\Program Files\nodejs\node_modules\