angular-fullstack / generator-angular-fullstack

Yeoman generator for an Angular app with an Express server
https://awk34.gitbook.io/generator-angular-fullstack
6.12k stars 1.24k forks source link

app generator fails: `Object #<Environment> has no method 'instantiate' ` #308

Closed foxyblocks closed 10 years ago

foxyblocks commented 10 years ago

Running yo angular-fullstack [app-name] fails with:

/usr/local/lib/node_modules/generator-angular-fullstack/node_modules/yeoman-generator/lib/base.js:551
    generator = this.env.instantiate(Generator, options);
                         ^
TypeError: Object #<Environment> has no method 'instantiate'
    at composeWith (/usr/local/lib/node_modules/generator-angular-fullstack/node_modules/yeoman-generator/lib/base.js:551:26)
    at yeoman.generators.Base.extend.compose (/usr/local/lib/node_modules/generator-angular-fullstack/app/index.js:194:10)
    at /usr/local/lib/node_modules/generator-angular-fullstack/node_modules/yeoman-generator/lib/base.js:387:14
    at processImmediate [as _immediateCallback] (timers.js:336:15)
DaftMonk commented 10 years ago

You need to be using version 1.2 of yo. Run npm update -g yo

mahulst commented 10 years ago

I am having the same error. Using npm list -g yo results in ├─┬ generator-angular-fullstack@2.0.4 │ └── yo@1.2.0 └── yo@1.2.0 Any ideas?

EDIT: I removed the nodejs installation, the node_modules folder and reinstalled everything. Seems to be working now. I suspect it had to do with me installing multiple versions of nodejs

frankcarey commented 10 years ago

Yeah, I'm getting this too with yo@1.2.1. Updating node from 10.25 to 10.31 (using sudo n stable) seems to have worked.

thomporter commented 10 years ago

Can we put something in the generator to check versions and error out when they're not where we want? Would save some folks some hair-pulling....

bernardocorbella commented 10 years ago

I'm getting this with yo@1.2.1 and node 0.10.31. I have fixed this by reverting to yo@1.2.0

danyim commented 10 years ago

I'm with @thomporter ... This has been a pain.

kingcody commented 10 years ago

Just for the record, I'm using yo@1.2.1 and node@0.10.31 with no such errors. I'm wondering if you guys are having issues related to global dependencies or npm cache.

I use nvm to manage my node versions and also separate global dependencies from the different versions of node. Also when fetching a new version of node, I typically clear my npm cache like so: npm cache clean before installing the globals for the new version (new as in: new to my system).

maluramichael commented 10 years ago

I got the same issue:

[?] Existing .yo-rc configuration found, would you like to use it? No
# Client

[?] What would you like to write scripts with? JavaScript
[?] What would you like to write markup with? HTML
[?] What would you like to write stylesheets with? Sass
[?] What Angular router would you like to use? uiRouter
[?] Would you like to include Bootstrap? Yes
[?] Would you like to include UI Bootstrap? Yes

# Server

[?] Would you like to use mongoDB with Mongoose for data modeling? Yes
[?] Would you scaffold out an authentication boilerplate? Yes
[?] Would you like to include additional oAuth strategies? Google, Facebook, Twitter
[?] Would you like to use socket.io? Yes

/usr/lib/node_modules/generator-angular-fullstack/node_modules/yeoman-generator/lib/base.js:562
    generator = this.env.instantiate(Generator, options);
                         ^
TypeError: Object #<Environment> has no method 'instantiate'
    at composeWith (/usr/lib/node_modules/generator-angular-fullstack/node_modules/yeoman-generator/lib/base.js:562:26)
    at yeoman.generators.Base.extend.compose (/usr/lib/node_modules/generator-angular-fullstack/app/index.js:223:10)
    at /usr/lib/node_modules/generator-angular-fullstack/node_modules/yeoman-generator/lib/base.js:395:14
    at processImmediate [as _immediateCallback] (timers.js:345:15)
npm -v
1.4.28
 nodejs -v
v0.10.32
yo -v
1.1.2

As you can see yo is on version 1.1.2 so i ran npm install yo@1.3.2. After that i checked the version again and it was still 1.1.2.

I think its a link problem. After i used nodejs /usr/lib/node_modules/yo/cli.js angular-fullstack everything generated fine cause in /usr/lib/node_modules/yo is the right version (1.3.2)

How can i fix this so i can just type yo instead of the full path?

kingcody commented 10 years ago

@maluramichael if you are on a "nix" like system you can run which yo to find out the location of the yo program that is executed when you omit the path.

maluramichael commented 10 years ago

@kingcody i'll try this tonight.

maluramichael commented 10 years ago
michael@synapse ~/development $ which yo
/usr/local/bin/yo
michael@synapse ~/development $ cd /usr/local/bin/
michael@synapse /usr/local/bin $ ls -la | grep yo
lrwxrwxrwx  1 root root   29 Okt 20 20:28 yo -> ../lib/node_modules/yo/cli.js
michael@synapse /usr/local/bin $ yo -v
1.1.2         
michael@synapse /usr/local/bin $ nodejs /usr/lib/node_modules/yo/
cli.js        node_modules/ package.json  readme.md     yoyo.js       
michael@synapse /usr/local/bin $ nodejs /usr/lib/node_modules/yo/cli.js -v
1.3.2
kingcody commented 10 years ago

So /usr/local/lib/node_modules/yo/cli.js is outdated but /usr/lib/node_modules/yo/cli.js is current. /usr/local is probably first in your path.

kingcody commented 10 years ago

$PATH

portokallidis commented 10 years ago

Can you point to a simple fix...until now i am doing 'node /usr/lib/node_modules/yo/cli.js angular-fullstack' instead of 'yo angular-fullstack' !!

robbyemmert commented 10 years ago

There is a common issue with NVM that can cause this issue. The issue happens as follows

  1. You want to install NVM, so you
  2. Uninstall nodejs and nvm (or worse, forget to uninstall them). NodeJS dutifully leaves behind your .npmrc config files (usually one in your local directory and another somewhere in /usr/local/).
  3. Install NVM
  4. Start using your preferred version of NodeJS.

At this point everything looks peachy, but the NVM node picks up on your old .npmrc files and will install everything into your old NPM directory (usually /usr/local/bin I think). You really don't want this, because it kind of defeats the purpose of NVM. You con confirm that this is your issue by running npm config get prefix. If the path you get looks like .nvm/something then you could have another problem. Otherwise, the following steps should clean things up:

  1. Delete everything nodey-looking in your prefix url (the one you looked up above).
  2. Run npm config get globalconfig and npm config get userconfig to get the location of your .npmrc files.
  3. Check /usr/local/bin for any files that look like node, nodejs, npm, or any npm programs you've got installed. I found binaries for node, npm, yo, express, grunt, and bower in there.
  4. Kill all those files with fire.
  5. Uninstall all versions of node you've installed via NPM: nvm uninstall [version]
  6. uninstall NVM. It's usually installed to ~/.nvm. rm -rf ~/.nvm ought to do the trick.
  7. re-install nvm and your preferred versions of Node. It will re-create your .npmrc files in the correct locations with the correct settings.
  8. Test the fix by running npm config get prefix. You should get .nvm/something.
  9. If you did, do the dance and install what you like. Confirm it installed to the correct location by installing yo then typing which yo. You should get a path like .nvm/somewhere/yo

Good luck

Awk34 commented 10 years ago

Very well crafted response @robbyemmert . +1 internet to you, sir.

portokallidis commented 10 years ago

Agreed with @Awk34 , thank you @robbyemmert , that helped a LOT!

np0x commented 9 years ago

make sure you also have yeoman installed correctly, you will see similar errors if you don't have bower, grunt-cli and gulp installed.

http://yeoman.io/learning/index.html