jmona789
jmona789

Reputation: 2839

Command not found after installing @vue/cli

I npm installed @vue/cli with npm install -g @vue/cli. but when I try the vue command I get -bash: vue: command not found. I added export PATH="/usr/local/Cellar/node/11.2.0/lib/node_modules/@vue/cli/bin:$PATH" to my bash profile and when I echo path in terminal I get

/usr/local/opt/openssl/bin:/usr/local/Cellar/node/11.2.0/lib/node_modules/@vue/cli/bin:/Users/jimmymona/.node/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Which does have the path to the vue cli in it: /usr/local/Cellar/node/11.2.0/lib/node_modules/@vue/cli/bin

I also tried sudo installing it but that didn't work either Anyone know what the issue is?

Upvotes: 0

Views: 731

Answers (1)

Haoqun Jiang
Haoqun Jiang

Reputation: 830

The path is wrong. The binary resides in /usr/local/Cellar/node/11.2.0/bin rather than .../lib/....

As you'll notice, the file in the latter directory is named as vue.js, not vue. NPM creates a symlink without the .js extension to it in the bin directory, and that's the actual binary we typically refer to.

Typically we don't use the full path in .bashrc directly (in case the npm global path changes). Rather, it's recommended to calculate it by combining the result of npm config get prefix and /bin, i.e.

export PATH="$PATH:$(npm config get prefix)/bin"

Upvotes: 3

Related Questions