Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yo unaware of installed generators

Tags:

npm

yeoman

I just installed Yeoman and some generators. However, because the /usr/lib folder is protected, I chose to change the prefix of the location where NPM installs its packages.

Right now, everything is getting installed under ~/.node. I also changed my $PATH and added ~/.node/bin. However, when I execute yo <name of generator>, I get the following:

Error node 

You don't seem to have a generator with the name node installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 0 registered generators run yo with the `--help` option.

As you can read here, it's telling me there are 0 registered generators, but I installed them correctly (and it completed without errors). I'm able to find the installed generators, for example ~/.node/lib/node_modules/generator-node exists and when I execute the following command:

npm list -g

I can find the generators that I installed (so I assume it isn't a problem with npm).

So I think Yeoman (or Yo to be more precisely) is unaware of the generators being installed in the custom folder, but I haven't found any way to configure this.

like image 384
g00glen00b Avatar asked Jan 01 '14 17:01

g00glen00b


2 Answers

In addition to adding it to your path, you should also set a NODE_PATH environment variable. The yeoman/generator code will look there first:

// We tried using NPM to get the global modules path, but it haven't work out
// because of bugs in the parseable implementation of `ls` command and mostly
// performance issues. So, we go with our best bet for now.
if (process.env.NODE_PATH) {
  _.compact(process.env.NODE_PATH.split(/[;:]/g)).forEach(this.appendPath, this);
  return;
}
like image 79
Stephen Avatar answered Oct 23 '22 19:10

Stephen


Looks like a NODE_PATH issue, try to execute the following command:

echo "export NODE_PATH=$NODE_PATH:/usr/local/lib/node_modules" >> ~/.bashrc && source ~/.bashrc^C

Or just type yo doctor to figure out what's happening

like image 2
Grzegorz Pawlik Avatar answered Oct 23 '22 21:10

Grzegorz Pawlik