[Yeoman] You don't seem to have a generator with the name chrome-extension installed.

Tadashi Shigeoka ·  Sat, June 28, 2014

I encountered an error where the generator couldn’t be found in an environment using nvm + Yeoman.

➜  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.

Even when running yo —help, none of the generators I thought I had installed were displayed…

➜  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.

The issue was that my PC’s default Node.js version was v0.10.26, while I had installed Yeoman on v0.10.29, and the environment variable $NODE_PATH wasn’t switching properly.

➜  echo $NODE_PATH
/Users/your_username/.nvm/v0.10.26/lib/node_modules

➜  echo $NVM_PATH
/Users/your_username/.nvm/v0.10.29/lib/node

The solution is to reset the NODE_PATH environment variable using NVM_PATH.

➜  export NODE_PATH=${NVM_PATH}_modules
➜  echo $NODE_PATH
/Users/your_username/.nvm/v0.10.29/lib/node_modules

However, setting NODE_PATH every time I switch with nvm use is honestly tedious.

I want NODE_PATH to switch along with nvm use.

So I defined export_node_path and nvmuse functions in .zshrc.

## 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

Now I can use the nvmuse command to switch Node.js versions and the NODE_PATH environment variable together.

➜  ~  node -v
v0.10.26
➜  ~  echo $NODE_PATH
/Users/your_username/.nvm/v0.10.26/lib/node_modules

➜  ~  nvmuse v0.10.29
Now using node v0.10.29
➜  ~  echo $NODE_PATH
/Users/your_username/.nvm/v0.10.29/lib/node_modules

There’s probably a better way to do this, but this works for now.


Reference Information

Yo doesn’t install any generators (nvm, node 0.10.24), yo 1.0.7-pre2 · Issue #125 · yeoman/yo

That’s all from the Gemba.