We are working as on a project with a couple of other devs on GIT, using the same repo, it works fine with everyone else. However, when I run grunt it executes multiple times, seems to be running into an infinite loop, without me actually making any changes. It's only happening to me on a different computer
I am considering that maybe I need something else installed.
I deleted node, npm and reinstalled with homebrew which I'm also using for updates. Node v5.3.0, npm 3.3.12
Running Mavericks.
What am I missing?
Here's the loop:
Reloading watch config...
Running "watch" task
Waiting...
>> File "Gruntfile.js" changed.
>> File "js/all-js/bootstrap-hover-dropdown.min.js" changed.
>> File "js/all-js/site.js" changed.
Running "uglify:build" (uglify) task
>> 1 file created.
Done, without errors.
Completed in 3.740s at Tue Jan 05 2016 13:11:07 GMT-0500 (ECT) - Waiting...
[BS] File changed: js/site.min.js
Reloading watch config...
Running "watch" task
Waiting...
>> File "js/all-js/bootstrap.js" changed.
>> File "Gruntfile.js" changed.
Running "uglify:build" (uglify) task
>> 1 file created.
Done, without errors.
Completed in 1.869s at Tue Jan 05 2016 13:11:10 GMT-0500 (ECT) - Waiting...
[BS] File changed: js/site.min.js
>> File "js/all-js/bootstrap-hover-dropdown.min.js" changed.
Running "uglify:build" (uglify) task
>> 1 file created.
Done, without errors.
Completed in 1.885s at Tue Jan 05 2016 13:12:04 GMT-0500 (ECT) - Waiting...
[BS] File changed: js/site.min.js
Reloading watch config...
Running "watch" task
Waiting...
>> File "Gruntfile.js" changed.
Here's my Gruntfile.js:
module.exports = function(grunt) {
//Get all tasks from the package.json file
require("matchdep").filterDev("grunt-*").forEach(grunt.loadNpmTasks);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/* Concurrent Task */
concurrent: {
watch: {
tasks: ['watch', 'compass:dist', 'browserSync'],
options: {
logConcurrentOutput: true
}
}
},
/* SASS task */
compass: {
dist: {
options: {
sassDir: ['SASS/'],
cssDir: ['css/'],
environment: 'development', /* development | production */
importPath: ['SASS/'],
outputStyle: 'compressed', /* expanded for development | compressed for production */
watch: true,
sourcemap: true
},
},
live: {
options: {
sassDir: ['SASS/'],
cssDir: ['css/'],
environment: 'production', /* development | production */
importPath: ['SASS/'],
outputStyle: 'compressed', /* expanded for development | compressed for production */
watch: false,
force: true,
},
},
},
/* Javascript Tasks */
uglify: {
// Uglify files
build: {
src: [
'js/all-js/bootstrap.js',
'js/all-js/site.js'
],
dest: 'js/site.min.js'
}
},
/* Run tasks when needed */
watch: {
js: {
files: ['js/all-js/*.js'],
tasks: ['uglify'],
options: { livereload: true }
},
gruntfile: {
files: ['Gruntfile.js'],
options: {reload: true}
}
},
/* Browser Reload with BrowserSync */
browserSync: {
bsFiles: {
src : [
'css/**/*.css',
'js/site.min.js',
'**/*.php'
]
},
}
});
// Where we tell Grunt what to do when we type "grunt" into the terminal.
grunt.registerTask('default', ['concurrent:watch']);
grunt.registerTask('live', ['compass:live']);
};
Here's my package.json file:
{
"name": "ourframework",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-compass": "*",
"grunt-browser-sync": "*",
"grunt-contrib-watch": "*",
"grunt-concurrent": "*",
"grunt-contrib-uglify": "*",
"matchdep": "*"
}
}
Look at the timestamps in the grunt output, eg:
Completed in 3.740s at Tue Jan 05 2016 13:11:10
Completed in 1.885s at Tue Jan 05 2016 13:12:04
Notice these compilations are a minute apart - you are running the grunt watch task. This will watch a set of specified files and re-run tasks if there are any changes.
There is no 'loop' - it will simply re-compile every time something changes, which is often desirable.
You can see your default task is set to concurrent:watch
grunt.registerTask('default', ['concurrent:watch']);
So if you just type grunt, it will run that task.
Related
After migrating to El Capitan, it seems users are experiencing an issue with grunt installations, possibly related to the rootless changes of El Capitan. In particular, running the grunt --force command results in EPERM errors. The workflow is as follows:
Assuming npm has been installed, navigate to the grunt directory with package.json and gruntfile.js and invoke grunt:
grunt --force
Example Gruntfile.js file contents:
module.exports = function(grunt) {
// All configuration goes here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
// Configuration for concatenating files goes here.
dist: {
src: [
'../js/libs/owl.carousel.js',
'../js/libs/jquery.actual.js',
'../js/libs/chosen.jquery.js',
'../js/libs/jquery.parallax.js',
'../js/src/common.js'
],
dest: '../js/pro/global.js',
},
},
uglify: {
build: {
src: '../js/pro/global.js',
dest: '../js/pro/global.min.js',
},
},
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: '../img/src/',
src: ['**/*.{png,jpg,gif}'],
dest: '../img/pro/'
}]
}
},
compass: {
dev: {
options: {
sassDir: '../sass',
cssDir: '../css',
fontsDir: '../fonts',
imagesDir: '../img/',
images: '../img/',
javascriptsDir: '../js/pro',
//environment: 'development',
outputStyle: 'compressed',
relativeAssets: true,
httpPath: '.',
}
},
},
watch: {
scripts: {
files: ['../js/**/**.js'],
tasks: ['concat', 'uglify'],
options: {
spawn: true,
},
},
images: {
files: ['../img/src/**.{png,jpg,gif}'],
tasks: ['imagemin'],
options: {
spawn: true,
}
},
compass: {
files: ['../**/*.{scss,sass}'],
tasks: ['compass:dev'],
}
},
svgstore: {
defaults: {
options: {
prefix : 'icon-',
},
files: {
'../img/svg-defs.svg': ['../img/svg/*.svg']
}
}
},
});
// Where we tell Grunt we plan to use this plug-in.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-svgstore');
// Where we tell Grunt what to do when we type "grunt" into the terminal.
grunt.registerTask('default', ['concat', 'uglify', /*'imagemin',*/ 'compass', 'svgstore', 'watch']);
};
Example package.json file contents:
{
"name": "Call Me Maybe",
"version": "0.2.0",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-compass": "^1.0.4",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-imagemin": "^0.9.4",
"grunt-contrib-sass": "^0.9.2",
"grunt-contrib-uglify": "^0.9.2",
"grunt-contrib-watch": "^0.6.1",
"grunt-svgstore": "^0.5.0"
}
}
The resulting EPERM errors are as follows:
Running "concat:dist" (concat) task
Warning: Unable to write "../js/pro/global.js" file (Error code: EPERM). Used --force, continuing.
Running "uglify:build" (uglify) task
Warning: Unable to write "../js/pro/global.min.js" file (Error code: EPERM). Used --force, continuing.
Running "compass:dev" (compass) task
Warning: Command failed: /bin/sh: compass: command not found. Used --force, continuing.
Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Used --force, continuing.
Running "svgstore:defaults" (svgstore) task
Warning: Unable to write "../img/svg-defs.svg" file (Error code: EPERM). Used --force, continuing.
Running "watch" task
Waiting...
Interestingly, Ruby and Compass are also installed, so it does align with the theory of the rootless unable to write to folders issues, but how can the dependency cores be moved elsewhere (i.e. /usr/local/bin) so this isn't an issue?
During the El Capitan Betas, some users suggested enabling root via terminal - though this seemingly no longer works, as the error persists and /usr/bin folder still doesn't allow for permission changes.
For those running into the same issue, I had to eliminate the use of binaries installed to the path: /usr/bin, and reinstall after updating the path /usr/local/bin. Ruby tended to be the primary culprit. Because I was struggling with locating all my ruby installs, I ended up installing rbenv to manage my ruby versions.
The following terminal commands may be helpful in identifying your problematic paths:
which ruby
gem environment
gem uninstall [insert gem name here]
[google how to set your paths to /usr/local/bin... (will be in a hidden file)]
gem install [insert gem name here]
Installing non-system software on /usr/bin is a bad move, and is now prohibited in El Capitan, and with good reason.
I am not familiar with grunt, but if you can get to use /usr/local/bin instead then probably everything works.
I'm looking at the grunt watch documentation but I can see how to run a separate process for my javascript files. Below is what I have for CSS:
GruntFile.js
module.exports = function(grunt) {
grunt.initConfig({
// running `grunt sass` will compile once
sass: {
dist: {
options: {
style: 'expanded'
},
files: {
'./public/css/sass_styles.css': './src/sass/sass_styles.scss' // 'destination': 'source'
}
}
},
// bring in additonal files that are not part of the sass styles set
concat: {
dist: {
src: [
'public/css/datepicker.css',
'public/css/jquery.tagsinput.css',
'public/css/sass_styles.css',
'application/themes/japantravel/style.css'
],
dest: 'public/css/all.css',
},
},
// running `grunt cssmin` will minify code to *.min.css file(s)
cssmin: {
minify: {
expand: true,
cwd: "public/css/",
src: ["all.css", "!*.min.css"],
dest: "public/css/",
ext: ".min.css"
}
},
// running `grunt watch` will watch for changes
watch: {
files: ["./src/sass/*.scss", "./src/sass/partials/*.scss"],
tasks: ["sass", "concat", "cssmin"]
}
});
// load tasks
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks("grunt-contrib-cssmin");
grunt.loadNpmTasks("grunt-contrib-watch");
};
As you can see I have tasks for CSS ["sass", "concat", "cssmin"], but I want to do separate tasks for separate files (js) - concat and minify - and listen for changes (watch). Can someone point me in the correct direction, I'm not really sure what I should be searching for. Is this something that watch can handle, or is there another plugin? I'm a little new to grunt so still trying to figure out how to use it. Thanks
You can use 'grunt-concurrent' for that, you can define multiple tasks with it. In combination with watch sets you will have the proper solution. https://github.com/sindresorhus/grunt-concurrent
# to install:
npm install grunt-concurrent --save-dev
And this will be your adjusted function then.
Remember, you still have to set some uglify and jshint properties! But I believe that's not the issue here.
module.exports = function(grunt) {
grunt.initConfig({
/* .. */
// running `grunt watch` will watch for changes
watch: {
// Use 'sets' like this, just make up a name for it:
watchCss: {
files: ["./src/sass/*.scss", "./src/sass/partials/*.scss"], // Directory to look for changes
tasks: ["concurrent:taskCss"] // Tasks you want to run when CSS changes
},
watchJs: {
files: ["./src/js/**/*.js"], // Directory to look for changes
tasks: ["concurrent:taskJs"] // Tasks you want to run when JS changes
}
},
concurrent: {
taskCss: ["sass", "concat", "cssmin"], // define the CSS tasks here
taskJs: ["jshint", "concat", "uglify"] // define the JS tasks here
},
});
// load tasks
grunt.loadNpmTasks("grunt-contrib-sass");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-cssmin");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks('grunt-contrib-jshint'); // Added
grunt.loadNpmTasks('grunt-contrib-uglify'); // Added
grunt.loadNpmTasks("grunt-concurrent"); // Added
// register tasks (note: you can execute sets from concurrent)
grunt.registerTask('default', ["concurrent:taskCss", "concurrent:taskJs"]);
grunt.registerTask('css', ["concurrent:taskCss"]);
grunt.registerTask('js', ["concurrent:taskJs"]);
};
To watch for changes:
grunt watch
# if a css file is changed, only the css tasks are performed
You can also execute a task from the prompt directly, for example:
grunt js
# This will only execute the registered task 'js'
# In this case that task points to 'concurrent:taskJs' wich will run jshint, concat and uglify
To install uglify and jshint:
https://github.com/gruntjs/grunt-contrib-uglify
https://github.com/gruntjs/grunt-contrib-jshint
npm install grunt-contrib-uglify --save-dev
npm install grunt-contrib-jshint --save-dev
I'm trying to write a grunt task which removes a directory and its contents.
Here is config file
{
"name": "lorem",
"homepage": "ipsum",
"version": "0.9.5",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-shell": "~0.5.0",
}
}
and grunt.js file
// Whole Gruntfile.js so far
module.exports = function(grunt) {
// 1. All configuration goes here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
shell: {
clean: {
command: 'rm dist -r',
options: { stdout: true, failOnError: true }
}
}
});
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('default', ['shell:clean']);
};
This probably work on linux, but what if the machine is windows or osx?
Is there any cross-platform solution to this?
Shell commands uses the system shell, which differs between OSes. If you want something cross-platform, just do it in JS. As for your use-case you could use grunt-contrib-clean, trash, or rimraf.
It is my first time trying to create a workflow with grunt I have manage to make almost all work but when I run grunt the watch task for sass does nothing just outputs that the file has changed and thats it no error code nothing
gruntfile.js:
'use strict';
module.exports = function(grunt) {
// All configuration goes here
grunt.initConfig({
//jekyll tasks
jekyll: {
//Builds jekyll to local development
dist: {
options: {
config: '_config_dev.yml',
dest: './_local',
}
},
//Builds jekyll for deploying
live: {
options: {
config: '_config.yml',
dest: './_live',
}
}
},
//jshint task
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: [
'./!Gruntfile.js',
'./assets/js/*.js',
'./assets/js/plugins/*.js',
'./!assets/js/scripts.min.js'
]
},
// Uglify
uglify: {
dist: {
files: {
'./assets/js/scripts.min.js': [
'./assets/js/plugins/*.js',
'./assets/js/_*.js'
]
}
}
},
//imagemin task
imagemin: {
dist: {
options: {
optimizationLevel: 7,
progressive: true
},
files: [{
expand: true,
cwd: './img/',
src: '{,*/}*.{png,jpg,jpeg}',
dest: './img/'
}]
}
},
//svgmin task
svgmin: {
dist: {
files: [{
expand: true,
cwd: './img/',
src: '{,*/}*.svg',
dest: './img/'
}]
}
},
//Sass tasks
sass: {
//Compiles sass to css for local test
dist: {
files: [{
expand: true,
cwd: 'assets/sass/',
src: ['**/*.scss'],
dest: 'assets/css/',
ext: '.css'
}]
},
//Compiles sass to css for live deployment
live: {
options: {
style: 'compressed'
},
files: [{
expand: true,
cwd: 'assets/sass',
src: ['**/*.scss'],
dest: 'assets/css',
ext: '.css'
}]
},
//Compiles sass for browser sync
style: {
options: {
style: 'compressed'
},
files: [{
expand: true,
cwd: 'assets/sass',
src: ['**/*.scss'],
dest: 'assets/css',
ext: '.css'
}]
},
},
//Watch tasks
watch: {
scss: {
files: 'assets/sass/*.scss',
task: ['clean', 'sass:dist'],
options: {
spaw: false,
},
},
style: {
files: 'assets/sass/*.scss',
task: ['sass:style'],
},
js: {
files: [
'<%= jshint.all %>'
],
tasks: ['jshint','uglify'],
},
jekyll: {
files: [
'_layouts/*.html',
'_includes/*.html',
'assets/css/main.css',
'*.html',
'*.md',
'_post/*.md'
],
tasks: ['jekyll:dist'],
},
livereload: {
options: {
livereload: true,
},
files: [
'_local/**'
],
},
},
//Clean task
clean: {
dist: [
'assets/css/main.css',
'assets/js/scripts.min.js'
]
},
//Server
connect: {
server : {
options: {
livereload: true,
base : './_local/',
port: 4000
}
}
}
});
// Load the plugins
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-svgmin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-jekyll');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-clean');
// Custom tasks
grunt.registerTask('dev', ['clean', 'sass:dist', 'uglify', 'imagemin','svgmin', 'jekyll:dist', 'connect:server', 'watch']);
grunt.registerTask('default', ['clean', 'sass:live', 'uglify','imagemin', 'svgmin', 'jekyll:live']);
grunt.registerTask('css', ['clean', 'sass:dist', 'uglify', 'imagemin','svgmin', 'jekyll:dist', 'connect:server', 'watch:style']);
};
My file structure is the next:
gruntfile.js
assets/
css/
sass/
And this is the output of the terminal when running grunt dev task as you see nothing changes
┌[~/git/Nutricorp] [dev *]← →[*+?]
└[ % ± ]>> grunt dev -v O_O
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Initializing config...OK
Registering "grunt-contrib-watch" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-watch/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-watch/package.json...OK
Loading "watch.js" tasks...OK
+ watch
Registering "grunt-contrib-imagemin" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-imagemin/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-imagemin/package.json...OK
Loading "imagemin.js" tasks...OK
+ imagemin
Registering "grunt-contrib-connect" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-connect/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-connect/package.json...OK
Loading "connect.js" tasks...OK
+ connect
Registering "grunt-svgmin" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-svgmin/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-svgmin/package.json...OK
Loading "svgmin.js" tasks...OK
+ svgmin
Registering "grunt-contrib-jshint" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-jshint/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-jshint/package.json...OK
Loading "jshint.js" tasks...OK
+ jshint
Registering "grunt-contrib-uglify" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-uglify/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-uglify/package.json...OK
Loading "uglify.js" tasks...OK
+ uglify
Registering "grunt-jekyll" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-jekyll/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-jekyll/package.json...OK
Loading "jekyll.js" tasks...OK
+ jekyll
Registering "grunt-contrib-sass" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-sass/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-sass/package.json...OK
Loading "sass.js" tasks...OK
+ sass
Registering "grunt-contrib-clean" local Npm module tasks.
Reading /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-clean/package.json...OK
Parsing /home/cruznick/git/Nutricorp/node_modules/grunt-contrib-clean/package.json...OK
Loading "clean.js" tasks...OK
+ clean
Loading "Gruntfile.js" tasks...OK
+ css, default, dev
Running tasks: dev
Running "dev" task
Running "clean" task
Running "clean:dist" (clean) task
Verifying property clean.dist exists in config...OK
Files: assets/css/main.css -> dist
Options: force=false, no-write=false
Options: force=false, no-write=false
Cleaning assets/css/main.css...OK
Running "sass:dist" (sass) task
Verifying property sass.dist exists in config...OK
Files: assets/sass/_config.scss -> assets/css/_config.css
Files: assets/sass/_grids.scss -> assets/css/_grids.css
Files: assets/sass/_main-page.scss -> assets/css/_main-page.css
Files: assets/sass/_menu.scss -> assets/css/_menu.css
Files: assets/sass/main.scss -> assets/css/main.css
Options: (none)
Writing assets/css/main.css...OK
File assets/css/main.css created.
Running "uglify" task
Running "uglify:dist" (uglify) task
Verifying property uglify.dist exists in config...OK
Files: [no src] -> ./assets/js/scripts.min.js
Options: banner="", footer="", compress={"warnings":false}, mangle={}, beautify=false, report="min"
>> Destination ./assets/js/scripts.min.js not written because src files were empty.
Running "imagemin" task
Running "imagemin:dist" (imagemin) task
Verifying property imagemin.dist exists in config...OK
Options: cache, optimizationLevel=7, progressive
Minified 0 images (saved 0 B)
Running "svgmin" task
Running "svgmin:dist" (svgmin) task
Verifying property svgmin.dist exists in config...OK
Options: (none)
Total saved: 0 B
Running "jekyll:dist" (jekyll) task
Verifying property jekyll.dist exists in config...OK
File: [no files]
Options: config="_config_dev.yml", dest="./_local"
`jekyll build --destination ./_local --config _config_dev.yml` was initiated.
Jekyll output:
Configuration file: _config_dev.yml
Source: /home/cruznick/git/Nutricorp
Destination: ./_local
Generating... done.
Running "connect:server" (connect) task
Verifying property connect.server exists in config...OK
File: [no files]
Options: protocol="http", port=4000, hostname="0.0.0.0", base="./_local/", directory=null, keepalive=false, debug=false, livereload, open=false, useAvailablePort=false, middleware=null
Started connect web server on http://0.0.0.0:4000
Running "watch" task
Waiting...Verifying property watch exists in config...OK
Verifying property watch.scss.files exists in config...OK
Verifying property watch.style.files exists in config...OK
Verifying property watch.js.files exists in config...OK
Verifying property watch.jekyll.files exists in config...OK
Live reload server started on port: 35729
Watching assets/sass/_config.scss for changes.
Watching assets/sass/_grids.scss for changes.
Watching assets/sass/_main-page.scss for changes.
Watching assets/sass/_menu.scss for changes.
Watching assets/sass/main.scss for changes.
Watching assets/sass/_config.scss for changes.
Watching assets/sass/_grids.scss for changes.
Watching assets/sass/_main-page.scss for changes.
Watching assets/sass/_menu.scss for changes.
Watching assets/sass/main.scss for changes.
Watching _layouts/main.html for changes.
Watching _includes/head.html for changes.
Watching _includes/menu.html for changes.
Watching assets/css/main.css for changes.
Watching index.html for changes.
Watching .git for changes.
Watching .sass-cache for changes.
Watching _includes for changes.
Watching _layouts for changes.
Watching _live for changes.
Watching _local for changes.
Watching _locales for changes.
Watching _plugins for changes.
Watching _posts for changes.
Watching assets for changes.
Watching img for changes.
Watching node_modules for changes.
Watching README.md for changes.
OK
>> File "assets/sass/_menu.scss" changed.
Live reloading assets/sass/_menu.scss...
Live reloading assets/sass/_menu.scss...
Completed in 0.002s at Thu Mar 27 2014 08:02:04 GMT-0600 (CST) - Waiting...
And I dont know why it doesnt work no error message any ideas thanks in advance
ps: also tried with grunt contrib compass and it didnt work i'm running archlinux with ruby 2.1.0p0 and sass and compass gems installed everything else works great
ps2: my shell is zsh if that is important
In your watch config you have task: instead of tasks:.
The key for specifying that property is plural.
I'm running Lion 10.9.2 with nodejs v0.10.26
I want to setup an automated compilation on sass files and a live reload with grunt, nothing complicated but...
When running grunt watch I get the following error
(node) warning: Recursive process.nextTick detected. This will break in the next version of node. Please use setImmediate for recursive deferral.
util.js:35
var str = String(f).replace(formatRegExp, function(x) {
^
RangeError: Maximum call stack size exceeded
here is the Gruntfile.js
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
files: {
'assets/css/styles.css': 'assets/sass/styles.scss'
}
}
},
watch: {
all: {
files: 'index.html', // Change this if you are not watching index.html
options: {
livereload: true // Set livereload to trigger a reload upon change
}
},
css: {
files: [ 'assets/sass/**/*.scss' ],
tasks: [ 'sass' ],
options: {
spawn: false
}
},
options: {
livereload: true // Set livereload to trigger a reload upon change
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.registerTask('watch', [ 'watch']);
grunt.registerTask('default', [ 'sass', 'watch' ]);
};
and here is the package.json
{
"name": "application",
"version": "0.0.1",
"private": true,
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-sass": "~0.7.3"
}
}
I finally figured out a similar problem I was having with SASS. I was using
grunt.registerTask('sass', [ 'sass']);
The trick was that Grunt doesn't seem to like the repetition in names. When I switch to
grunt.registerTask('styles', [ 'sass']);
Everything worked as it should.
Just had this problem. Resolved it by removing grunt.registerTask('watch', [ 'watch']);
I just fixed a similar error "Recursive process.nextTick detected" causing by command: grunt server
The solution? Use sudo grunt serve instead
you could try this one, it fixed the issue for me, working with Yeoman 1.3.3 and Ubuntu 14.04 Grunt watch error - Waiting...Fatal error: watch ENOSPC
I was getting error in even trying to install grunt. Running npm dedupe solved my problem as answered here: Grunt watch error - Waiting...Fatal error: watch ENOSPC
Alternative solution: check your watch for an empty file argument.
Here's an excerpt of my gruntfile
watch: {
all: {
options:{
livereload: true
},
files: ['src/scss/*.scss', 'src/foo.html',, 'src/bar.html'],
tasks: ['default']
}
}
In my case, I could recreate the original poster's error on demand with the empty argument above.