Yo unaware of installed generators

2019-04-09 02:05发布

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.

标签: npm yeoman
2条回答
聊天终结者
2楼-- · 2019-04-09 02:27

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

查看更多
Rolldiameter
3楼-- · 2019-04-09 02:40

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;
}
查看更多
登录 后发表回答