I have an error executing "grunt server" :
Running "brunch:server" (brunch) task result in Fatal error: spawn ENOENT
Here you can find my dependencies from package.json :
"dependencies": {
"javascript-brunch": "1.7.0",
"coffee-script-brunch": "1.7.2",
"css-brunch": "1.7.0",
"stylus-brunch": "1.7.0",
"handlebars-brunch": "1.7.2",
"uglify-js-brunch": "1.7.3",
"clean-css-brunch": "1.7.1",
"jsenv-brunch": "1.4.2",
"auto-reload-brunch": "1.7.1",
"moment": "2.4.0",
"lodash": "2.4.0",
"grunt": "0.4.2",
"grunt-contrib-clean": "0.5.0",
"grunt-contrib-copy": "0.4.1",
"grunt-brunch": "0.0.2",
"grunt-shell": "0.6.1",
"grunt-contrib-htmlmin": "0.1.3",
"grunt-line-remover": "0.0.2"
},
"devDependencies": {},
"peerDependencies": {
"grunt": "0.4.2"
}
And here part of my gruntfile :
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
brunch: {
options: {
env: ['<%= company %>', '<%= platform %>'],
production: '<%= production %>'
},
build: {},
watch: {
options: {
watch: true
}
},
server: {
options: {
server: true
}
}
},
});
grunt.loadNpmTasks('grunt-brunch');
grunt.loadTasks('tasks');
grunt.registerTask('server', [
'init',
'clean:build',
'brunch:server'
]);
I tried many things nothing works, any ideas will be welcoming ?
The issue is due to the path settings in the task file: ./node_modules/grunt-brunch/tasks/brunch.coffee. As it is set now the brunch binary is not found leading to the ENOENT error. If you change the path to:
BASE = "#{__dirname}/../../../"
in line #2 of the task file, the binary is found and the plugin works.
EDIT: The issue only happens if there is a brunch installed locally on the base dir. In this case it seems brunch is NOT installed into the npm-modules of the grunt-brunch package (where the path is pointing to)
npm install --save brunch
The grunt-brunch plugin expects brunch to be a local dependency of your project. It is not set up to use a global brunch installation.
Related
Hi I am trying to learn grunt tutorial from youtube and I am following the same instruction as mention in the video.
But while running the command grunt in my system I am getting the error , which I am not able to resolve it.
Below is my package.json
{
"name": "shreyansh",
"version": "1.0.0",
"description": "running grunt test",
"main": "index.html",
"author": "shreyansh",
"devDependencies": {
"grunt": "^1.0.1",
"grunt-contrib-cssmin": "^1.0.2",
"grunt-contrib-uglify": "^2.0.0"
}
}
Gruntfile.js
module.exports = funtion(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
cssmin: {
combine:{
files:{
'Project/css/main.css': [ 'file-upload.css']
}
}
}
});
grunt.LoadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask('default', ['cssmin'])
};
Error : -
Loading "Gruntfile.js" tasks...ERROR >> SyntaxError: Unexpected token {
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
I tried to look for the similar errors questions from stackoverflow but no luck.
Any help is appreciated as I am using grunt first time
Thanks
Fix the typo in line 1 of your gruntfile, change funtion to function:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
cssmin: {
combine:{
files:{
'Project/css/main.css': [ 'file-upload.css']
}
}
}
});
grunt.LoadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask('default', ['cssmin'])
};
Haven been playing with this for several hours
package.json
{
"name": "compile-tests",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"grunt": "^0.4.5",
"assemble": "^0.7.3"
}
}
Gruntfile.js
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
assemble: {
options: {
flatten: true,
layout: "../templates/1.hbs"
},
pages: {
files: {
'../dist' : ['../pages/*.hbs']
}
}
}
});
grunt.loadNpmTasks('assemble');
grunt.registerTask('default', ['assemble']);
};
Tried removing and re-installing all the modules a few times. And also tried different versions, interestingly the versions mentioned in this article http://blog.parkji.co.uk/2013/07/06/building-a-static-site-using-grunt-and-assemble.html seem to work but then I get other issues because those versions are out of date.
Error
$ Grunt
>> Local Npm module "assemble" not found. Is it installed?
Warning: Task "assemble" not found. Used --force, continuing.
I just had to use grunt-assemble
$ npm install grunt-assemble --save-dev
And adjust this line in the Gruntfile.js
grunt.loadNpmTasks('grunt-assemble');
I have a linux symlink to a folder called node_modules in my folder with the grunt file but when I run grunt I get this:
Local Npm module "jshint-stylish" not found. Is it installed?
All my other npm modules work fine,any ideas?
my grunt file:
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-open');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-closure-compiler');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('jshint-stylish');
permissions:
me#pc:~/dev/root/node_modules$ ls -l
total 96
..
drwxr-xr-x 3 me me 4096 Jun 10 14:57 grunt-shell
drwxr-xr-x 3 me me 4096 Jun 10 15:00 jshint-stylish
..
EDIT_____________________
I'm using it in grunt as a reporter:
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [
Try installing the module manually.
npm install jshint-stylish
worked for me.
The load-grunt-configs owner creynders suggests here that the error
"Local Npm module 'jshint-stylish' not found. Is it installed?"
is apparently caused by the requiring of jshint-stylish in the jshint.js config file.
It can't find the jshint-stylish module since it's in a directory outside the project.
However I was unable to make his suggestion working for me, but I found my own way:
// gruntfile.js
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
config: grunt.file.readJSON('grunt-config.json'),
jshint_reporter: require('jshint-stylish')
});
// grunt-config.json
{
"jsHintFiles" : [
"**/modules/*.js"
]
}
// jshint.js
module.exports = function(grunt) {
"use strict";
grunt.config.merge({"jshint": {
"default": {
options: {
reporter: "<%= jshint_reporter %>"
},
src: ["<%= config.jsHintFiles %>"]
}
}});
};
Check that your NODE_PATH environment variable references your node_modules directory.
Locally it will be:
export NODE_PATH=./node_modules
My grunt doesn't give any output, and I just installed all the system, NPM and grunt-cli. When I type "grunt -v" nothing is returned.
This is my package.json:
{
"name": "project",
"version": "2.0.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-coffee": "~0.7.0",
"grunt-contrib-compass": "~0.6.0",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-watch": "~0.5.3",
"grunt-yui-compressor": "~0.3.0",
"grunt-contrib-cssmin": "~0.7.0"
}
}
And my Gruntfile.coffee is:
module.exports = (grunt) ->
# Project configuration.
grunt.initConfig
pkg: grunt.file.readJSON("package.json")
coffee:
glob_to_multiple:
expand: true
flatten: true
src: ['assets/javascripts/source/*.coffee']
dest: 'assets/javascripts/build/'
ext: '.js'
compass:
dev:
options:
config: 'config.rb'
cssmin:
add_banner:
options:
banner: '/* Compilado em ' + grunt.template.today('dd/mm/yyyy') + ' */'
files:
'assets/styles/build/site.min.css': ['assets/styles/build/site.css']
'assets/styles/build/site-ie7.min.css': ['assets/styles/build/site-ie7.css']
uglify:
dev:
files:
'assets/javascripts/build/scripts.min.js':[
'assets/javascripts/build/scripts.js'
'assets/javascripts/build/zt-validator.js'
'assets/javascripts/build/jquery-zt.js'
]
dist:
files:
'assets/javascripts/build/scripts-full.min.js':[
'assets/javascripts/build/scripts.js'
'assets/javascripts/build/zt-validator.js'
'assets/javascripts/build/jquery-zt.js'
'assets/javascripts/build/site.js'
]
watch:
options: { spawn: false }
coffee:
files: ["assets/javascripts/source/*.coffee"]
tasks: ["coffee","uglify"]
compass:
files: ["assets/styles/**/*.sass","assets/styles/**/*.scss"]
tasks: ["compass","cssmin"]
grunt.loadNpmTasks "grunt-contrib-coffee"
grunt.loadNpmTasks "grunt-contrib-watch"
grunt.loadNpmTasks "grunt-contrib-compass"
grunt.loadNpmTasks "grunt-contrib-cssmin"
grunt.loadNpmTasks "grunt-contrib-uglify"
# Default task(s).
grunt.registerTask "default", ["coffee", "compass"]
I don't know how to debug it.
Try removing the package "node". It's not related to NodeJS and removing it resolved the problem for me.
You can accomplish this by running sudo apt-get remove node and reinstall nodejs-legacy with sudo apt-get install nodejs-legacy
I had to install 'node-legacy' on Ubuntu 13.10 in order to get 'grunt' working. Just installing 'node' was not enough.
If you aren't on the latest version of grunt-cli, upgrade it.
You might be getting caught by the problem this update fixed and that likely explains the different results you and I are getting with the switches.
So I'm making my own Wordpress Framework, and am utilizing grunt and sass. I'm newer at grunt and sass, but experienced enough with grunt to kind of know what I'm doing, but I've used LESS in the past and not Sass.
I'm taking the Gruntfile.js file from roots.io as a starting point. Everything I have is correct as far as I know, but I'm not too sure about a couple of things. I removed the js stuff because I'm not going to be watching for it, and I added grunt-contrib-sass.
When running grunt watch I get this error:
grunt watch
/Gruntfile.js:22
watch: {
^^^^^
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Unexpected identifier
Warning: Task "watch" not found. Use --force to continue.
Aborted due to warnings.
Below is my Gruntfile.js and my package.json
Gruntfile.JS
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
version: {
options: {
file: 'lib/scripts.php',
css: 'assets/css/main.min.css',
cssHandle: 'su_styles'
}
},
sass: {
dist: {
options: {
style: 'compressed'
},
files: {
'assets/css/main.min.css': [
'assets/scss/app.scss'
]
}
}
},
watch: {
sass: {
files: [
'assets/scss/*.scss',
'assets/scss/foundation/*.scss'
],
tasks: ['sass', 'version']
},
livereload: {
// Browser live reloading
// https://github.com/gruntjs/grunt-contrib-watch#live-reloading
options: {
livereload: false
},
files: [
'assets/css/main.min.css',
'templates/*.php',
'*.php'
]
}
},
clean: {
dist: [
'assets/css/main.min.css'
]
}
});
// Load tasks
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-wp-version');
grunt.loadNpmTasks('grunt-contrib-sass');
// Register tasks
grunt.registerTask('default', [
'clean',
'version',
'sass'
]);
grunt.registerTask('dev', [
'watch'
]);
};
package.json - with some stuff taken out to preserve a bit of privacy
{
"name": "sudoh",
"version": "1.0.0",
"author": "Brandon Shutter <brandon#brandonshutter.com>",
"licenses": [
{
"type": "MIT",
"url": "http://opensource.org/licenses/MIT"
}
],
"engines": {
"node": ">= 0.10.0"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-wp-version": "~0.1.0",
"grunt-contrib-sass": "~0.5.0"
}
}
Thanks for your help ahead of time.
It seems there wasn't anything wrong with my setup. My code editor (Brackets) added hidden characters for whatever reason and was causing a syntax error. Switching over to Sublime and saving the file again allowed it work perfectly.
Thanks for the help everyone.