简体   繁体   English

已安装Grunt,但“未找到命令”

[英]Grunt installed but “command not found”

I'm trying to use Grunt on a project that I'm working on with someone else. 我正在尝试在与他人合作的项目中使用Grunt。 My colleague installed Node, NPM, Grunt-CLI and created a Grunt task and uploaded the entire working directory to Github. 我的同事安装了Node,NPM,Grunt-CLI,并创建了Grunt任务,并将整个工作目录上传到Github。 When he runs the Grunt task it works fine. 当他运行Grunt任务时,它可以正常工作。

I have Yosemite 10.10.4. 我有优胜美地10.10.4。 I've pulled down a clone of the working directory from Github. 我已经从Github删除了工作目录的克隆。 But when I try and run the Grunt task I get >> /bin/sh: mysqldump: command not found Database dump failed! 但是当我尝试运行Grunt任务时,我得到了>> /bin/sh: mysqldump: command not found Database dump failed!

I have done the following: 我已经完成以下工作:

  • Installed Node.js 已安装的Node.js
  • Installed the command-line version of Grunt sudo npm install -g grunt-cli 安装了Grunt命令行版本sudo npm install -g grunt-cli
  • Added the path from the Grunt installer to my $PATH export PATH=/usr/local/lib/node_modules/grunt-cli/bin:$PATH then echo $PATH which results in /usr/local/lib/node_modules/grunt-cli/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin 添加了从Grunt安装程序到我的$ PATH export PATH=/usr/local/lib/node_modules/grunt-cli/bin:$PATH然后echo $PATH导致/usr/local/lib/node_modules/grunt-cli/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin
  • Ensured grunt is installed grunt --version results in grunt-cli v0.1.13 grunt v0.4.5 确保已安装grunt-cli v0.1.13 grunt v0.4.5 grunt --version导致grunt-cli v0.1.13 grunt v0.4.5
  • Installed Grunt in to the working directory cd /path/to/project/root/ followed by sudo npm install 将Grunt安装到工作目录cd /path/to/project/root/然后sudo npm install
  • Checked and ensured package.json and Gruntfile.js are in the root of the working directory (also of note that a node_modules folder has been included in the root of the working directory with my colleagues commit). 检查并确保package.json和Gruntfile.js位于工作目录的根目录中(还要注意,在同事提交的情况下,node_modules文件夹已包含在工作目录的根目录中)。

Is anyone able to help me identify the problem? 有人可以帮助我确定问题吗?

I've been following: 我一直在关注:

http://gruntjs.com/getting-started http://gruntjs.com/getting-started

http://www.hongkiat.com/blog/grunt-command-not-found/ http://www.hongkiat.com/blog/grunt-command-not-found/

As arco444 has said I needed to install the mysqldump plugin. 正如arco444所说,我需要安装mysqldump插件。

https://www.npmjs.com/package/grunt-mysql-dump https://www.npmjs.com/package/grunt-mysql-dump

I hadn't realised that mysqldump was refering to a plugin, I had presumed that it was the name of the task that my colleague had created so I was just expecting that to be part of the work he had done to create the Grunt task in one of the associated configuration files. 我没有意识到mysqldump指的是插件,我以为这是我的同事创建的任务的名称,因此我只是希望这将成为他在其中创建Grunt任务所做的工作的一部分。关联的配置文件之一。

If you're using MAMP, then mysql command line tools are not made available in your PATH automatically. 如果您使用的是MAMP,则PATH不会自动提供mysql命令行工具。 For the above plugin to work, you must find out the path to these tools (On Mac OS: bundled in MAMP.app; on Windows/Linux: probably within the app's directory tree) and add that path to your PATH environment variable! 为了使上述插件正常工作,您必须找出这些工具的路径(在Mac OS上:捆绑在MAMP.app中;在Windows / Linux上:可能在应用程序的目录树中),然后将该路径添加到PATH环境变量中!

In my case that was export PATH=/Applications/MAMP/Library/bin:$PATH 在我的情况下是export PATH=/Applications/MAMP/Library/bin:$PATH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM