I am working on a webapp built by someone else...the commands to build and run are
npm install
bower install
grunt serve
I have used npm and bower with no problems before..everything seems to work until grunt reaches the 'connect:livereload" task, when the command line just hangs, with no error messages.
Below is the package.json file and the output from grunt serve -v:
(package.json)
{
"name": "app",
"version": "0.0.1",
"dependencies": {
"openlayers": "^3.14.2"
},
"devDependencies": {
"connect-livereload": "^0.5.3",
"grunt": "^0.4.5",
"grunt-bower-requirejs": "^2.0.0",
"grunt-browserify": "^4.0.1",
"grunt-connect-proxy": "^0.2.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-connect": "^0.10.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-cssmin": "^0.12.3",
"grunt-contrib-handlebars": "^0.10.2",
"grunt-contrib-imagemin": "^0.9.4",
"grunt-contrib-jshint": "^0.11.2",
"grunt-contrib-less": "^1.2.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-jsbeautifier": "^0.2.10",
"grunt-jscs": "^1.8.0",
"grunt-jsdoc": "^0.6.7",
"grunt-karma": "^0.11.0",
"grunt-open": "^0.2.3",
"grunt-processhtml": "^0.3.8",
"grunt-requirejs": "^0.4.2",
"grunt-usemin": "^3.0.0",
"jit-grunt": "^0.9.1",
"jscs": "^1.13.1",
"jscs-stylish": "^0.3.1",
"jsdoc": "^3.3.2",
"jshint-stylish": "^2.0.0",
"karma": "^0.13.0",
"karma-chai": "^0.1.0",
"karma-chai-sinon": "^0.1.5",
"karma-chrome-launcher": "^0.1.12",
"karma-coverage": "^0.4.2",
"karma-firefox-launcher": "^0.1.6",
"karma-ie-launcher": "^0.2.0",
"karma-jasmine": "^0.3.6",
"karma-phantomjs-launcher": "^0.2.0",
"karma-requirejs": "^0.2.2",
"mocha-xunit-zh": "0.0.3",
"phantomjs": "^1.9.17",
"requirejs": "^2.1.18",
"time-grunt": "^1.2.1"
},
"engines": {
"node": ">=0.12.0"
}
}
(verbose) output (starting at live:reload)
Running "connect:livereload" (connect) task
Verifying property connect.livereload exists in config...OK
File: [no files]
Options: protocol="http", port=9001, hostname="0.0.0.0", base=".", directory=nul
l, keepalive=false, debug=false, livereload=false, open=false, useAvailablePort=
false, onCreateServer=null, middleware=undefined
Here is the (non-verbose) output after running 'grunt serve':
$ grunt serve
Running "serve" task
Running "clean:server" (clean) task
>> 1 path cleaned.
Running "jshint:all" (jshint) task
√ No problems
Running "jscs:src" (jscs) task
No code style errors found.
>> 21 files without code style errors.
Running "createDefaultTemplate" task
Running "handlebars:compile" (handlebars) task
>> 1 file created.
Running "clean:dist" (clean) task
>> 1 path cleaned.
Running "createDefaultTemplate" task
Running "handlebars:compile" (handlebars) task
>> 1 file created.
Running "less:dist" (less) task
>> 1 stylesheet created.
Running "copy:env" (copy) task
Copied 1 file
Running "copy:ol" (copy) task
Copied 2 files
Running "configureProxies" task
Proxy created for: /api to 52.20.39.250:80
Running "connect:livereload" (connect) task
Here is gets stuck (at ' Running "connect:livereload" (connect) task')... no cursor or errors or any further output.... Here I would expect to see "Started connect web server on http://localhost:9001" and be able to view the app, but instead it hangs here, with no further output or errors until I force quit. Nothing is served to that port (I tried switching port numbers as a test in the grunt-task/config/connect file of the app, but no change)
Here is the Gruntfile:
'use strict';
module.exports = function (grunt) {
// show elapsed time at the end
require('time-grunt')(grunt);
// load all grunt tasks
require('jit-grunt')(grunt, {
useminPrepare: 'grunt-usemin',
configureProxies: 'grunt-connect-proxy'
});
var yeomanConfig = {
app: 'app',
dist: 'dist'
};
grunt.initConfig({yeoman: yeomanConfig});
//load all custom task configs
grunt.loadTasks('grunt-tasks/config');
grunt.loadTasks('grunt-tasks/register');
grunt.registerTask('default', [
'jshint',
'jscs',
//'test',
'build'
]);
};
Here is the 'connect' file, in grunt-tasks/config:
module.exports = function(grunt) {
var SERVER_PORT = 9001;
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({
port: LIVERELOAD_PORT
});
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
// configurable paths
var yeomanConfig = {
app: 'app',
dist: 'dist'
};
grunt.config('connect', {
options: {
port: grunt.option('port') || SERVER_PORT,
hostname: '0.0.0.0'
},
proxies: [{
context: ['/api'],
host: 'HOST IP',
port: 80
}],
livereload: {
options: {
middleware: function (connect) {
return [
proxySnippet,
lrSnippet,
mountFolder(connect, '.tmp'),
connect().use(
'/node_modules',
connect.static('./node_modules')
),
mountFolder(connect, yeomanConfig.app)
];
}
}
},
test: {
options: {
middleware: function (connect) {
return [
lrSnippet,
mountFolder(connect, '.tmp'),
mountFolder(connect, 'test'),
mountFolder(connect, yeomanConfig.app)
];
}
}
},
testInBrowser: {
options: {
middleware: function (connect) {
return [
proxySnippet,
mountFolder(connect, '.tmp'),
mountFolder(connect, 'test'),
mountFolder(connect, yeomanConfig.app)
];
}
}
},
dist: {
options: {
middleware: function (connect) {
return [
proxySnippet,
connect().use(
'/node_modules',
connect.static('./node_modules')
),
mountFolder(connect, yeomanConfig.dist)
];
}
}
}
});
}
One thing I noticed: when in the webapp for lder of this project, my npm version is 2.14.20, but in my user folder, the npm version is 3.8.3 (in both directories, my version of Node is the same, 4.4.1) .. could this be a source of this problem? I just ran npm install npm -g in the webapp directory, but it did not change the version when viewed from that directory.