generator-angular icon indicating copy to clipboard operation
generator-angular copied to clipboard

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

Open ghost opened this issue 9 years ago • 7 comments

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:

  • Mac 10.11.2
  • node 5.5.0 - regular install, not via Macports/Homebrew
  • npm 3.3.12
  • yo 1.6.0

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

ghost avatar Jan 21 '16 18:01 ghost

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

isaacerd avatar Jan 26 '16 14:01 isaacerd

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

ghost avatar Jan 29 '16 15:01 ghost

The Comant Is success??

isaacerd avatar Jan 29 '16 15:01 isaacerd

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?

rakeshmishrait avatar May 01 '16 11:05 rakeshmishrait

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.

c29130811 avatar May 09 '16 07:05 c29130811

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.

medianetix avatar Jun 03 '16 18:06 medianetix

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

Karbophos avatar Jul 03 '16 11:07 Karbophos