Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the --gruntfile option broken in grunt-cli 0.1.9 ? #26

Closed
pixelzoom opened this issue Jul 22, 2013 · 22 comments
Closed

Is the --gruntfile option broken in grunt-cli 0.1.9 ? #26

pixelzoom opened this issue Jul 22, 2013 · 22 comments

Comments

@pixelzoom
Copy link

I upgraded from grunt-cli 0.1.6 to 0.1.9, using 'npm install -g grunt-cli'

% npm --version
1.3.4
% grunt --version
grunt-cli v0.1.9
grunt v0.4.1
%

Our build process uses a Gruntfile.js that is shared by multiple projects, so we use the --gruntfile option when invoking grunt. Here's what happens after updating grunt-cli:

% grunt --gruntfile ../Gruntfile.js
grunt-cli: The grunt command line interface. (v0.1.9)

Fatal error: Unable to find local grunt.

If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:

http://gruntjs.com/getting-started
grunt failed
%

'npm ls' shows that I have a local grunt installed ([email protected]).

If I copy Gruntfile.js to the current directory and run 'grunt', everything is fine. This is part of a build process that has been working smoothly for quite some time, and we've made no changes to that build process other than to update grunt-cli.

@pixelzoom
Copy link
Author

Reverting to grunt-cli 0.1.8 fixes the problem: sudo npm install -g [email protected]

So this would appear to be something that was introduced in 0.1.9.

@samreid
Copy link

samreid commented Jul 22, 2013

I'm having the same problem. Here is my version information:

Windows 8 x64
$ npm --version
1.3.2

$ grunt --version
grunt-cli v0.1.9
grunt v0.4.1

@paynecodes
Copy link

Could this have anything to do with:

If youre seeing this message, either a Gruntfile wasnt found or 'grunt
hasnt been installed locally to your project'. For more information about
installing and configuring grunt, please see the Getting Started guide:

You say that you have installed it globally.

@pixelzoom
Copy link
Author

Please re-read the original report. I indicated that I installed grunt-cli globally and grunt locally, as recommended by the grunt installation instructions. The grunt-cli is installed globally in /usr/local/bin/grunt. And grunt is installed locally, as verified by 'npm ls | grep grunt'.

@pixelzoom
Copy link
Author

The complete steps I followed to install grunt-cli globally and grunt locally, and the resulting error.

% sudo npm install -g grunt-cli
% grunt --version
grunt-cli v0.1.9
grunt v0.4.1
% cd my-project
% cat package.json
{
  "name": "my-project",
  "version": "0.0.0-1",
  "license": "GPLv3",
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-requirejs": "~0.3.2",
    "grunt-contrib-jshint": "~0.5.4"
  }
}
% npm install
% npm ls | grep grunt
├─┬ grunt@0.4.1
├─┬ grunt-contrib-jshint@0.5.4
└─┬ grunt-requirejs@0.3.5
  ├─┬ grunt-backbonebuilder@0.1.4
   └─┬ grunt@0.3.17
  ├─┬ grunt-jquerybuilder@0.1.4
   ├─┬ grunt-contrib-jshint@0.1.1
   ├─┬ grunt-contrib-nodeunit@0.1.2
   ├─┬ grunt-contrib-watch@0.2.0
  ├─┬ grunt-lodashbuilder@0.1.7
   ├─┬ grunt-contrib-jshint@0.1.1
   ├─┬ grunt-contrib-nodeunit@0.1.2
   ├─┬ grunt-contrib-watch@0.2.0
% grunt --gruntfile ../chipper/grunt/Gruntfile.js
grunt-cli: The grunt command line interface. (v0.1.9)

Fatal error: Unable to find local grunt.

If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:

http://gruntjs.com/getting-started
grunt failed
%

@paynecodes
Copy link

My apologies. I, too am running into this issue now. I had some tasks that were using the Gruntfile.js rather than my altGruntfile.js. So, I removed Gruntfile.js and boom... Fatal error: Unable to find Gruntfile. Even though, I am trying to run this grunt build --gruntfile altGruntfile.js.

I tried sudo npm install -g [email protected], but still receive the same error.

$ grunt --version
grunt-cli v0.1.8
grunt v0.4.1

@pixelzoom Did you do anything other than revert to grunt-cli v0.1.8 to get this working?

@pixelzoom
Copy link
Author

The only thing I did to workaround this was to revert to the previous version of grunt-cli:

sudo npm install -g grunt-cli@0.1.8

@pixelzoom
Copy link
Author

Actually... I might have reverted to 0.1.6 first, because that's the version I had before updating. Then I updated to 0.1.8.

@paynecodes
Copy link

Would you happen to be running grunt-concurrent?

If so, please see my issue here: sindresorhus/grunt-concurrent#17

Perhaps this is affecting more than just grunt-concurrent.

@pixelzoom
Copy link
Author

I'm not intentionally using grunt-concurrent. How can I confirm?

@paynecodes
Copy link

Look in package.json. Also check in Gruntfile for 'concurrent'. My problems was the fact that I was using the --gruntfile argument while using a grunt plugin that didn't properly support passing those arguments around. See my issue sindresorhus/grunt-concurrent#17

Your issue doesn't seem to be the same because a downgrade worked for you, while that didn't work for me. But, just check to see if you are running any tasks that might have the same issue.

@pixelzoom
Copy link
Author

Complete package.json was provided above. No 'concurrent' in Gruntfile.

@pixelzoom
Copy link
Author

The only tasks I'm running in Gruntfile are these:

grunt.loadNpmTasks( 'grunt-requirejs' );
grunt.loadNpmTasks( 'grunt-contrib-jshint' );

Running jshint first on all .js source files. Then running requirejs:build.

@paynecodes
Copy link

Hmm... It's not grunt-concurrent then. I was able to find out it was grunt-concurrent because the Fatal error: Unable to find local grunt. logged just before my concurrent task ran. In other words, several of my tasks would run, then once it got to concurrent it would log out the fatal error. Similar for you? Or, is it simply logging out fatal error immediately?

@pixelzoom
Copy link
Author

Mine is logging out fatal immediately, even when trying to do nothing but jshint.

@paynecodes
Copy link

Oh wow.. Sorry, I couldn't help. First time using Grunt.

@pixelzoom
Copy link
Author

Thanks for trying. We'll wait for the next release and keep our fingers crossed :)

@beninfobelt
Copy link

Am also experiencing an issue with Gruntfile.js. I am trying to clone a project from github then set up the bower dependencies and grunt build / dev tools.

After cloning the project, I run the bower command so that it reads through bower.json:

% bower install

Then I run the grunt commands:

% npm install -g grunt-cli
% npm install grunt --save-dev

Why is the Gruntfile.js not automatically created when I run these terminal commands?

It also hangs up on an issue related to livereload but that evaporates after I run these:

% npm install --save-dev connect-livereload
% npm install

When I start a project from scratch with these yeoman and grunt commands, it automatically creates the Gruntfile.js and I can successfully get the project to auto-load in the browser:

% npm install -g generator-angular
% yo angular
% bower install angular-ui
% npm install --save-dev connect-livereload
% npm install
% grunt test
% grunt server
% grunt

But I am trying to master the technique of cloning a project from github and then setting up the project locally. I would be very grateful for any direction you could provide. All the best,

Ben

@paynecodes
Copy link

@beninfobelt Hmm... This seems like a bit of a mess with all the commands. I can't necessarily help you with the specifics, but have you tried going through the Yeoman Getting Started Guide?

@beninfobelt says:

When I start a project from scratch with these yeoman and grunt commands, it automatically creates the Gruntfile.js and I can successfully get the project to auto-load in the browser:

I would recommend you walk through it in a clean project directory like you did above.

Then, you can use Bower to install front-end dependencies, npm to install node dependencies that don't already come with Yeoaman (see package.json), and Grunt to compile and package your application.

@beninfobelt says:

But I am trying to master the technique of cloning a project from github and then setting up the project locally. I would be very grateful for any direction you could provide.

This isn't the proper place for the high-level direction you wish to have. If you post somewhere else, please feel free to post a link here, and I'll help you the best I know how.

@beninfobelt
Copy link

@vladikoff
Copy link
Member

@pixelzoom moving this issue to gruntjs/grunt#950
Please comment there if you still have this issue.
Thanks for your patience!

@cowboy cowboy reopened this Jan 22, 2014
@cowboy cowboy closed this as completed in db61cee Jan 22, 2014
@cowboy
Copy link
Member

cowboy commented Jan 22, 2014

You should now be able to use the --base option to specify the working directory from where Grunt should run. This is also where the CLI looks for the node_modules folder, where a locally-installed Grunt should live.

By default, if --base isn't used, the CLI looks in the folder the Gruntfile is in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants