第一步:
1先確定一下.bash_profile是否存在.
2在mac終端輸入:
test -e .bash_profile && echo "found" || echo "not found"
3.bash_profile是一個環境配置的腳本, 如果顯示的是not found, 則在終端運行
touch ~/.bash_profile
運行完之后重復2, 顯示found, 則表明創建成功
第二步:
1安裝grunt-cli
sudo npm install -g grunt-cli
2在終端通過命令的形式打開第一步中的.bash_profile文件, 命令如下:
open -a TextEdit ~/.bash_profile
3將環境配置寫入你打開的.bash_profile, 然后保存ctrl+s, 然后退出即可, 注意路徑每個人有所不同, 要看自己grunt-cli的安裝路徑是什么, 路徑填錯無效
export PATH=/usr/local/Cellar/node/6.7.0/libexec/npm/lib/node_modules/grunt-cli/bin:$PATH
第三步:
1 在終端運行: source ~/.bash_profile
2 在終端運行: grunt --version
如果它正常工作的話, 你將看到grunt-cli 的版本號,like this
END