Multiple Grunt tasks not found - gruntjs

I am trying to build a yeoman generator and using the tutorial as a guide
http://yeoman.io/generators.html#writing-your-first-generator
I copied the Gruntfile.js from the gist referenced and put it in my generator's template directory. When I generate the project, I run
npm install && bower install
then
grunt test
Local Npm module "grunt-template-jasmine-requirejs" not found. Is it installed?
Warning: Task "concurrent:test" not found. Use --force to continue.
Aborted due to warnings.
Execution Time (2014-01-10 16:19:20 UTC)
loading tasks 3ms
▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 50%
test 2ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 33%
Total 6ms
It is not clear to me why Grunt concurrent:test is not found. Grunt finds the clean:test task. I tried commenting the concurrent task and none of the other tasks were found for "test" except "clean". Here is the task list
grunt.registerTask('test', [
'clean:server',
'concurrent:test',
'autoprefixer',
'connect:test',
'karma'
]);
Good point jakerella I see now I was using different grunt file in my yeoman generator then I intended. When I replace Gruntfile.js with the one from the gist referenced in the yeoman tutorial, I get the same issue with a different task. Its says "watch" is not found.
$ ls node_modules/
bower grunt-contrib-compass grunt-contrib-jshint grunt-template-jasmine-requirejs
connect-livereload grunt-contrib-concat grunt-contrib-jst grunt-usemin
grunt grunt-contrib-connect grunt-contrib-livereload load-grunt-tasks
grunt-bower-requirejs grunt-contrib-copy grunt-contrib-requirejs matchdep
grunt-connect-proxy grunt-contrib-cssmin grunt-contrib-uglify moment
grunt-contrib-clean grunt-contrib-htmlmin grunt-open time-grunt
grunt-contrib-coffee grunt-contrib-imagemin grunt-regarde
$ grunt server
>> Local Npm module "grunt-template-jasmine-requirejs" not found. Is it installed?
Warning: Task "watch" not found. Use --force to continue.
Aborted due to warnings.
$

I had the same problem. I solved it by running:
npm install grunt-x --save-dev replacing x with the name of the missing task repeatedly until done.
Incidentally I has first tried npm install -g grunt-x and that didn't work.

After some work at identifying dependencies, I was able to get this to work once I copied the entire foundation app directory and then used the foundation5 generator's index.js list of files to copy from the template directory as a guide to additional resources that were required by my generator. I think this may be a helpful way for anyone trying to repurpose existing generators and help identify Grunt dependencies.

Related

>> Error: Cannot find module 'load-grunt-config' how can I get grunt to work?

I've cloned a repo that I'm supposed to be working on.
I then tried running the following commands:
npm install
bower install
As well as: cd to my folder and npm install grunt --save-dev
However, when I run grunt I get the following error:
Loading "Gruntfile.js" tasks...ERROR
>> Error: Cannot find module 'load-grunt-config'
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
Execution Time (2018-05-07 11:23:14 UTC+10)
loading tasks 6ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 86%
Total 7ms
This is my Gruntfile.js:
module.exports = function(grunt) {
require('time-grunt')(grunt);
require('load-grunt-config')(grunt, {
jitGrunt: true
});
};
How can I fix this? I am really stuck.
it seems like you don't have 'load-grunt-config' installed (at least I get the exact same error by removing the folder from my node_modules).
run npm install load-grunt-config and/or fix your package.json file by adding "load-grunt-config": "^0.19.2"to the related dependencies.

Why does grunt allow global installations?

I've installed both the grunt-cli and grunt globally using the -g option.
However when I try and run grunt I get this error:
grunt --gruntfile /Users/a/root/config/Gruntfile.js
grunt-cli: The grunt command line interface. (v0.1.13)
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
This is confusing as it seems to say that you are suppose to do a local install.
It seems contradictory actually. I clearly have a grunt file in place.
Grunt-cli is installed globally so that the grunt command is available to be run from any location on your system. Without the global installation, you would need to rely on somewhat abstract methods of running local grunt installs (npm run-script and friends), which are clunky for this use.
The entire point of the global install is only to load and run a local Gruntfile.js using the locally installed version of Grunt. The error message indicates this:
either a Gruntfile wasn't found or grunt hasn't been installed locally to your project.
In other words, to run Grunt, you need to create a Gruntfile.js and you must have a local copy of Grunt installed to your project alongside the file. The CLI is just there to kick off the process without troublesome fiddling.

Grunt command - unable to find local grunt

I copied an existing Grunt project from git repo and when i run - grunt serve-dev command it tells me the following:
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
But if i - grunt -version it says:grunt-cli v0.1.13.
What might be the issue?
Be sure to run npm install after cloning the repo. Usually the node_modules, such as grunt aren't included the repo itself by default, but you must install them yourself.

Yeoman error launching project with "grunt" command

I was following yeoman tutorial http://yeoman.io/codelab/prepare-production.html and everything worked fine until I tried to launch my project with "grunt" command then I got the following error:
Running "autoprefixer:dist" (autoprefixer) taskAutoprefixer's process() method is deprecated and will removed in next major release. Use postcss([autoprefixer]).process() insteadFile .tmp/styles/main.css created.
jit-grunt: Plugin for the "ngtemplates" task not found.If you have installed the plugin already, please setting the static mapping.See https://github.com/shootaroo/jit-grunt#static-mappings
Warning: Task "ngtemplates" failed. Use --force to continue.
Aborted due to warnings.
I use Linux Mint 17
A workaround was posted at the generator-angular github. Try modifying your Gruntfile.js to make the jit-grunt block look like this:
// Automatically load required Grunt tasks
require('jit-grunt')(grunt, {
useminPrepare: 'grunt-usemin',
ngtemplates: 'grunt-angular-templates',
cdnify: 'grunt-google-cdn'
});
This is a issue for grunt-autoprefixer which is deprecated.
I am guessing, you installed a old version of generator-angular and current version of grunt which is written in the tutorial with following commands.
npm install --global yo bower grunt-cli
npm install --global generator-angular#0.11.1
It is better to install the current version of generator-angular. Just run this and start over again.
npm install -g generator-angular

Grunt+Foundation: css/foundation.css created, content [object Object]

I just got started with Bolt.cm (CMS) which comes along with Foundation for frontend.
I've installed Node, NPM, Node-sass, Bower and Grund and started a "grunt watch" in the theme directory.
Grunt is running ("waiting") and when I edit a file in the scss folder (the one from the theme of course, not from the bower_components, I know I should not edit them) the task is successfully executed:
Running "sass:dist" (sass) task.
File "css/foundation.css" created.
Done, without errors.
Theme & versions:
I copied this theme to modify it locally: https://github.com/bolt/base-2014
Grunt version is grunt-cli v0.1.13
NPM version 1.3.10
bower version 1.4.1
The problem
When i open css/foundation.css, the file does not contain CSS code, but only [object Object] as text.
This is the output when i run grunt --verbose:
grunt --verbose
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Registering "grunt-sass" local Npm module tasks.
Reading /var/www/bolt/theme/avoe/node_modules/grunt-sass/package.json...OK
Parsing /var/www/bolt/theme/avoe/node_modules/grunt-sass/package.json...OK
Loading "sass.js" tasks...OK
+ sass
Registering "grunt-contrib-watch" local Npm module tasks.
Reading /var/www/bolt/theme/avoe/node_modules/grunt-contrib-watch/package.json...OK
Parsing /var/www/bolt/theme/avoe/node_modules/grunt-contrib-watch/package.json...OK
Loading "watch.js" tasks...OK
+ watch
Loading "Gruntfile.js" tasks...OK
+ build, default
No tasks specified, running default tasks.
Running tasks: default
Running "default" task
Running "build" task
Running "sass" task
Running "sass:dist" (sass) task
Verifying property sass.dist exists in config...OK
Files: scss/foundation.scss -> css/foundation.css
Options: includePaths=["bower_components/foundation/scss"], outputStyle="compressed", sourceComments="none"
Writing css/foundation.css...OK
File "css/foundation.css" created.
I managed to fix this issue by going into node_modules folder, removing and reinstalling grunt-sass and node-sass:
rm -rf node-sass
rm -rf grunt-sass
npm install node-sass
npm install grunt-sass
The reinstallation of grunt sass updated my foundation-libsass-template repo, which is where i think the issue may have lay.
It may be that you don't even need to touch node-sass, so perhaps give grunt-sass a go first.
Hope this helps.

Resources