我刚安装了Yeoman和一些发电机.但是,由于该/usr/lib
文件夹受到保护,我选择更改NPM安装其包的位置的前缀.
现在,一切都安装在~/.node
.我也改变了我的意见$PATH
并补充说~/.node/bin
.但是,当我执行时yo
,我得到以下内容:
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
存在,当我执行以下命令时:
npm list -g
我可以找到我安装的生成器(所以我认为它不是npm的问题).
所以我认为Yeoman(或更确切地说是Yo)并不知道自定义文件夹中安装的生成器,但我没有找到任何方法来配置它.
除了将其添加到路径之外,还应设置NODE_PATH
环境变量.该自耕农/发电机的代码将在那里寻找第一:
// 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; }