5

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.

g00glen00b
  • 41,995
  • 13
  • 95
  • 133

2 Answers2

8

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;
}
Stephen
  • 5,710
  • 1
  • 24
  • 32
  • 1
    Thanks, I executed `export NODE_PATH=$HOME/.node/lib/node_modules/` and that indeed seems to solve the issue. – g00glen00b Jan 02 '14 at 13:57
  • 2
    yo doctor tells you about these things. Kind of dumb in my opinion, if it has a "doctor" mode, it should run it by default if you have a problem – Milimetric Jun 27 '14 at 17:18
2

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

Grzegorz Pawlik
  • 2,198
  • 1
  • 18
  • 18