终端无法识别最近安装的 CLI

终端无法识别最近安装的 CLI

我正在使用 Ubuntu 16.04,并尝试通过运行以下命令安装 vue-cli:

npm install -g vue-cli

这是输出:

npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
/home/gabriel/.npm-global/bin/vue-init -> /home/gabriel/.npm-global/lib/node_modules/vue-cli/bin/vue-init
/home/gabriel/.npm-global/bin/vue -> /home/gabriel/.npm-global/lib/node_modules/vue-cli/bin/vue
/home/gabriel/.npm-global/bin/vue-list -> /home/gabriel/.npm-global/lib/node_modules/vue-cli/bin/vue-list
+ [email protected]
updated 2 packages in 18.669s

(我再次运行该命令以获取输出,这就是它显示已更新的原因)

但是,终端无法识别命令“vue”:

No command 'vue' found, did you mean:
 Command 'vpe' from package 'texlive-latex-extra' (universe)
vue: command not found

目录 /home/gabriel/.npm-global/lib/node_modules/vue-cli/bin/vue-init 包含:

-rwxrwxr-x 1 gabriel gabriel  380 jun  4 22:47 vue*
-rwxrwxr-x 1 gabriel gabriel  309 oct  1  2017 vue-build*
-rwxrwxr-x 1 gabriel gabriel  438 may 31 12:00 vue-create*
-rwxrwxr-x 1 gabriel gabriel 3.9K feb  4  2018 vue-init*
-rwxrwxr-x 1 gabriel gabriel  775 oct  1  2017 vue-list*

每当我尝试安装任何新的 CLI 时,都会发生这种情况。Laravel 安装程序也会发生这种情况,如果我尝试运行安装命令,它会告诉我它已经安装,但就像 vue-cli 一样,它无法识别该命令:

gabriel@gabriel /v/w/h/test> composer global require "laravel/installer"
Changed current directory to /home/gabriel/.config/composer
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Using version ^2.0 for laravel/installer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
gabriel@gabriel /v/w/h/test> laravel new app
laravel: command not found

以前不会发生这种情况。例如,因为我能够成功安装 composer 和 npm。

什么原因导致了这个问题?

提前致谢!

编辑。- 我尝试在 ~/.profile 中将环境变量添加到 PATH,但这似乎也不起作用。文件如下所示:

# set PATH so it includes user's private bin directories
PATH="$HOME/bin:$HOME/.local/bin:$HOME/.npm-global/lib/node_modules/vue-cli/bin:$PATH"
# Ubuntu make installation of Ubuntu Make binary symlink
PATH=/home/gabriel/.local/share/umake/bin:$PATH

相关内容