問題描述
通過官方指令
npm install -g @vue/cli
# 全局安裝 vue-cli
$ npm
install
--global vue-cli
# 建立一個基于 webpack 模闆的新項目
$ vue init webpack my-project
但是
安裝vue腳手架提示:
No command ‘vue’ found, did you mean:
Command ‘vpe’ from package ‘texlive-latex-extra’ (universe)
vue: command not found
下圖所示:

解決方案
(1)嘗試了網上很多關于建立軟連接配接的方式
(2)嘗試過 whereis vue 建立軟連接配接的方式,但是本虛拟機 輸出結果: vue:
[email protected]: whereis vue
[email protected]: vue:
- 1
- 2
這種方案未能解決所遇到的問題。
解決方案
(1)嘗試了網上很多關于建立軟連接配接的方式
(2)嘗試過 whereis vue 建立軟連接配接的方式,但是本虛拟機 輸出結果: vue:
[email protected]: whereis vue
[email protected]: vue:
這種方案未能解決所遇到的問題。
(3)方案三
第一步: 在任意位置輸入指令
[email protected]: mkdir ~/.npm-global
第二步:在任意位置 輸入
[email protected]: npm config set prefix '~/.npm-global'
第三步: 在 ~/.profile 檔案中追加
export PATH=~/.npm-global/bin:$PATH
// 這一步可能會存在疑惑,具體在哪裡操作
本人嘗試在 ~/.profile中的倒數第二行追加,具體操作如下
[email protected]: vim ~/.profile
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
export PATH=~/.npm-global/bin:$PATH
mesg n || true
第四步:更新系統變量
[email protected]: source ~/.profile
第五步:
npm install -g jshint
再次運作 vue --version,已經顯示成功安裝
@vue/cli 4.2.3