我是Grunt的新手.我正在尝试在我的Mac OSX Lion上配置Grunt.
我按照这里的说明进行操作,然后创建了一个包含以下文件的项目文件夹.当我尝试通过在终端输入"grunt"来运行时,我得到了command not found.我也修改了我的路径sudo nano /etc/paths,希望添加路径会使任务运行器工作,但它仍然无法正常工作.有人可以协助吗?
---paths
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/local/bin/grunt
--- files
node modules
Gruntfile.js
package.json
Run Code Online (Sandbox Code Playgroud)
小智 491
我对Mountain Lion的解决方法是: -
npm install -g grunt-cli
Run Code Online (Sandbox Code Playgroud)
在http://gruntjs.com/getting-started上看到它
nsc*_*nni 43
我猜你用Brew来安装Node,所以这里的指南可能会有用http://madebyhoundstooth.com/blog/install-node-with-homebrew-on-os-x/.
您需要确保npm/bin位于您描述的路径中export PATH="/usr/local/share/npm/bin:$PATH".这是npm将为已安装的软件包安装bin存根的位置.
纳米版本也将如http://architectryan.com/2012/10/02/add-to-the-path-on-mac-os-x-mountain-lion/所述,但终端重启可能是要求获得新路径.
我一直在寻找解决这个问题一段时间,并且没有任何建议的bash更新似乎有效.我发现的是,某些点我的npm根被修改,以至于它指向了Users/USER_NAME/.node/node_modulesnpm的实际安装时间/usr/local/lib/node_modules.您可以通过运行npm root和npm root -g(对于全局安装)进行检查.要更正您可以呼叫的路径npm config set prefix /usr/local.
同样在OS X(El Capitan)上,整个上午都有同样的问题.
我在我的项目所在的目录中运行命令"npm install -g grunt-cli"命令.
我再次尝试从我的主目录(即'cd~')并像以前一样安装,除了现在我可以运行grunt命令并且它被识别.
关键是找到安装 grunt 的正确路径。我通过 npm 安装了 grunt,但我的 grunt 路径是/Users/${whoyouare}/.npm-global/lib/node_modules/grunt/bin/grunt. 所以在我添加/Users/${whoyouare}/.npm-global/lib/node_modules/grunt/bin到~/.bash_profile,and 之后source ~/.bash_profile,它起作用了。
所以步骤如下:
1. find the path where your grunt was installed(when you installed grunt, it told you. if you don't remember, you can install it one more time)
2. vi ~/.bash_profile
3. export PATH=$PATH:/your/path/where/grunt/was/installed
4. source ~/.bash_profile
你可以参考 http://www.hongkiat.com/blog/grunt-command-not-found/