解决mac安装grunt时出现[command not found]的错误

第一步:

  1先确定一下.bash_profile是否存在.

  2在mac终端输入:

    test -e .bash_profile && echo "found" || echo "not found"

解决mac安装grunt时出现[command not found]的错误_第1张图片

  3.bash_profile是一个环境配置的脚本, 如果显示的是not found, 则在终端运行

    touch ~/.bash_profile

    运行完之后重复2, 显示found, 则表明创建成功

第二步:

  1安装grunt-cli

    sudo npm install -g grunt-cli

解决mac安装grunt时出现[command not found]的错误_第2张图片

  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

解决mac安装grunt时出现[command not found]的错误_第3张图片

第三步:

 1 在终端运行: source ~/.bash_profile

 2 在终端运行: grunt --version

 如果它正常工作的话, 你将看到grunt-cli 的版本号,like this

你可能感兴趣的:(解决mac安装grunt时出现[command not found]的错误)