[Yeoman] You don’t seem to have a generator with the name chrome-extension installed.
- 2014 6/28
nvm + Yeoman という環境で generator が見つからないというエラーに陥りました。
➜ yo chrome-extension
Error chrome-extension
You don't seem to have a generator with the name chrome-extension 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. |
yo –help してみてもインストールしたはずの generator が何も表示されない・・・。
➜ yo --help Usage: yo GENERATOR [args] [options] General options: -h, --help # Print generator's options and usage -f, --force # Overwrite files that already exist Please choose a generator below. |
自分のPC環境の Node.js のデフォルトバージョンが v0.10.26 で、今回 Yeoman をインストールしていたのが v0.10.29 で、環境変数 $NODE_PATH の設定が切り替わってないのが原因でした。
➜ echo $NODE_PATH /Users/bakorer/.nvm/v0.10.26/lib/node_modules ➜ echo $NVM_PATH /Users/bakorer/.nvm/v0.10.29/lib/node |
環境変数 NODE_PATH を NVM_PATH を使って、再設定すれば解決です。
➜ export NODE_PATH=${NVM_PATH}_modules ➜ echo $NODE_PATH /Users/bakorer/.nvm/v0.10.29/lib/node_modules |
でも、nvm use で切替えたときに、毎回 NODE_PATH をセットするのは正直メンドイ。
nvm use で一緒に NODE_PATH も切り替えたい。
というわけで、.zshrc に export_node_path と nvmuse 関数を定義しました。
## nvm if [[ -f ~/.nvm/nvm.sh ]]; then source ~/.nvm/nvm.sh if which nvm >/dev/null 2>&1 ;then export_node_path () { export NODE_PATH=${NVM_PATH}_modules } nvmuse () { nvm use $1 export_node_path } export_node_path fi fi |
これで nvmuse コマンドを使って、Node.js のバージョン切替えと、環境変数 NODE_PATH を一緒に切替えられるようになりました。
➜ ~ node -v v0.10.26 ➜ ~ echo $NODE_PATH /Users/bakorer/.nvm/v0.10.26/lib/node_modules ➜ ~ nvmuse v0.10.29 Now using node v0.10.29 ➜ ~ echo $NODE_PATH /Users/bakorer/.nvm/v0.10.29/lib/node_modules |
もっと良い方法ありそうだけど、とりあえずこれで良いかな。
参考情報
・Yo doesn't install any generators (nvm, node 0.10.24), yo 1.0.7-pre2 · Issue #125 · yeoman/yo