你不知道安装的发电机 [英] Yo unaware of installed generators

查看:56
本文介绍了你不知道安装的发电机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了 Yeoman 和一些生成器.但是,由于 /usr/lib 文件夹受到保护,我选择更改 NPM 安装其包的位置的前缀.

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.

现在,一切都安装在 ~/.node 下.我还更改了我的 $PATH 并添加了 ~/.node/bin.但是,当我执行 yo 时,我得到以下信息:

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.

正如您在此处阅读的那样,它告诉我有 0 个已注册的生成器,但我正确安装了它们(并且没有错误地完成).我能够找到已安装的生成器,例如 ~/.node/lib/node_modules/generator-node 存在并且当我执行以下命令时:

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

我可以找到我安装的生成器(所以我认为这不是 npm 的问题).

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

所以我认为 Yeoman(或更准确地说是 Yo)不知道在自定义文件夹中安装了生成器,但我还没有找到任何配置它的方法.

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.

推荐答案

除了将它添加到您的路径之外,您还应该设置一个 NODE_PATH 环境变量.自耕农/生成器代码将首先查看:>

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;
}

这篇关于你不知道安装的发电机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆