我的问题与此类似:Grunt won't load the node server
但是,在我的情况下,答案并不能解决问题。这是我的 gruntfile:
'use strict';
module.exports = function(grunt) {
// Unified Watch Object
var watchFiles = {
serverViews: ['app/views/**/*.*'],
serverJS: ['gruntfile.js', 'server.js', 'config/**/*.js', 'app/**/*.js'],
clientViews: ['public/modules/**/views/**/*.html'],
clientJS: ['public/js/*.js', 'public/modules/**/*.js'],
clientCSS: ['public/modules/**/*.css', 'public/lib/bootstrap/dist/css/icomoon.css'],
mochaTests: ['app/tests/**/*.js']
};
// Project Configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
serverViews: {
files: watchFiles.serverViews,
options: {
livereload: true
}
},
serverJS: {
files: watchFiles.serverJS,
tasks: ['jshint'],
options: {
livereload: true
}
},
clientViews: {
files: watchFiles.clientViews,
options: {
livereload: true,
}
},
clientJS: {
files: watchFiles.clientJS,
tasks: ['jshint'],
options: {
livereload: true
}
},
clientCSS: {
files: watchFiles.clientCSS,
tasks: ['csslint'],
options: {
livereload: true
}
}
},
jshint: {
all: {
src: watchFiles.clientJS.concat(watchFiles.serverJS),
options: {
jshintrc: true
}
}
},
csslint: {
options: {
csslintrc: '.csslintrc',
},
all: {
src: watchFiles.clientCSS
}
},
uglify: {
production: {
options: {
mangle: false
},
files: {
'public/dist/application.min.js': 'public/dist/application.js'
}
}
},
cssmin: {
combine: {
files: {
'public/dist/application.min.css': '<%= applicationCSSFiles %>'
}
}
},
nodemon: {
dev: {
script: 'server.js',
options: {
file: 'server.js',
nodeArgs: ['--debug'],
ext: 'js,html',
watch: watchFiles.serverViews.concat(watchFiles.serverJS)
}
}
},
'node-inspector': {
custom: {
options: {
'web-port': 1337,
'web-host': 'localhost',
'debug-port': 5858,
'save-live-edit': true,
'no-preload': true,
'stack-trace-limit': 50,
'hidden': []
}
}
},
ngAnnotate: {
production: {
files: {
'public/dist/application.js': '<%= applicationJavaScriptFiles %>'
}
}
},
concurrent: {
default: ['nodemon', 'watch'],
debug: ['nodemon', 'watch', 'node-inspector'],
options: {
logConcurrentOutput: true,
limit: 10
}
},
env: {
test: {
NODE_ENV: 'test'
},
secure: {
NODE_ENV: 'secure'
}
},
mochaTest: {
src: watchFiles.mochaTests,
test: {
options: {
require: 'server.js',
reporter: 'spec'
}
}
},
karma: {
unit: {
configFile: 'karma.conf.js'
}
}
});
// Load NPM tasks
require('load-grunt-tasks')(grunt);
// Making grunt default to force in order not to break the project.
grunt.option('force', true);
// A Task for loading the configuration object
grunt.task.registerTask('loadConfig', 'Task that loads the config into a grunt option.', function() {
var init = require('./config/init')();
var config = require('./config/config');
grunt.config.set('applicationJavaScriptFiles', config.assets.js);
grunt.config.set('applicationCSSFiles', config.assets.css);
});
// Default task(s).
grunt.registerTask('default', ['lint', 'concurrent:default']);
// Debug task.
grunt.registerTask('debug', ['lint', 'concurrent:debug']);
// Secure task(s).
grunt.registerTask('secure', ['env:secure', 'lint', 'concurrent:default']);
// Lint task(s).
grunt.registerTask('lint', ['jshint', 'csslint']);
// Build task(s).
grunt.registerTask('build', ['lint', 'loadConfig', 'ngAnnotate', 'uglify', 'cssmin']);
// Test tasks.
grunt.registerTask('test', ['env:test', 'mochaTest', 'karma:unit']);
grunt.registerTask('test-front', ['env:test', 'karma:unit']);
grunt.registerTask('test-back', ['env:test', 'mochaTest']);
};
当我运行 grunt(忽略 lint 错误)时,我得到:
Running "concurrent:default" (concurrent) task
Running "watch" task
Running "nodemon:dev" (nodemon) task
Waiting...
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: app/views/**/*.* gruntfile.js server.js config/**/*.js app/**/*.js
[nodemon] starting `node --debug server.js`
它就停在那里......通常它会说 MEANjs 应用程序已在 localhost:3000 上启动,当我在浏览器中打开应用程序时,它会显示大量文件,因为它们是通过浏览器请求和加载的。
这是 grunt -v 版本(观看的文件太多,所以为了清晰和简洁我删除了一些):
Running "nodemon" task
Running "nodemon:dev" (nodemon) task
Verifying property nodemon.dev exists in config...OK
File: [no files]
Options: file="server.js", nodeArgs=["--debug"], ext="js,html", watch=["app/views/**/*.*","gruntfile.js","server.js","config/**/*.js","app/**/*.js"]
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: app/views/**/*.* gruntfile.js server.js config/**/*.js app/**/*.js
[nodemon] starting `node --debug server.js`
Loading "grunt-karma.js" tasks...OK
+ karma
Loading "gruntfile.js" tasks...OK
+ build, debug, default, lint, loadConfig, secure, test, test-back, test-front
Running tasks: watch
Running "watch" task
Waiting...
Verifying property watch exists in config...OK
Verifying property watch.serverViews.files exists in config...OK
Verifying property watch.serverJS.files exists in config...OK
Verifying property watch.clientViews.files exists in config...OK
Verifying property watch.clientJS.files exists in config...OK
Verifying property watch.clientCSS.files exists in config...OK
Live reload server started on port: 35729
Watching app/views/404.server.view.html for changes.
Watching app/views/templates for changes.
Watching app/views/500.server.view.html for changes.
Watching app/views/index.server.view.html for changes.
Watching app/views/layout.server.view.html for changes.
Watching app/views/templates/reset-password-confirm-email.server.view.html for changes.
Watching app/views/templates/reset-password-email.server.view.html for changes.
Watching gruntfile.js for changes.
Watching .git for changes.
Watching app for changes.
Watching config for changes.
Watching node_modules for changes.
Watching public for changes.
Watching server.js for changes.
Watching config/config.js for changes.
Watching config/env for changes.
Watching config/strategies for changes.
Watching config/express.js for changes.
Watching config/init.js for changes.
Watching config/passport.js for changes.
Watching config/env/all.js for changes.
Watching config/env/development.js for changes.
Watching config/env/production.js for changes.
Watching config/env/secure.js for changes.
Watching config/env/test.js for changes.
Watching config/strategies/facebook.js for changes.
Watching config/strategies/github.js for changes.
Watching config/strategies/google.js for changes.
Watching config/strategies/linkedin.js for changes.
Watching config/strategies/local.js for changes.
Watching config/strategies/twitter.js for changes.
Watching app/controllers/alerts.server.controller.js for changes.
Watching app/controllers/users for changes.
Watching app/controllers/bundles.server.controller.js for changes.
Watching app/controllers/configurations.server.controller.js for changes.
Watching app/controllers/core.server.controller.js for changes.
Watching app/controllers/devices.server.controller.js for changes.
Watching app/controllers/errors.server.controller.js for changes.
Watching app/controllers/invitations.server.controller.js for changes.
Watching app/controllers/orders.server.controller.js for changes.
Watching app/controllers/projects.server.controller.js for changes.
Watching app/controllers/readings.server.controller.js for changes.
Watching app/controllers/services.server.controller.js for changes.
Watching app/controllers/users.server.controller.js for changes.
Watching app/controllers/users/users.authentication.server.controller.js for changes.
Watching app/controllers/users/users.authorization.server.controller.js for changes.
Watching app/controllers/users/users.list.server.controller.js for changes.
Watching app/controllers/users/users.password.server.controller.js for changes.
Watching app/controllers/users/users.profile.server.controller.js for changes.
Watching app/models/alert.server.model.js for changes.
Watching app/models/bundle.server.model.js for changes.
Watching app/models/configuration.server.model.js for changes.
Watching app/models/device.server.model.js for changes.
Watching app/models/invitation.server.model.js for changes.
Watching app/models/order.server.model.js for changes.
Watching app/models/project.server.model.js for changes.
Watching app/models/reading.server.model.js for changes.
Watching app/tests/order.server.routes.test.js for changes.
Watching app/tests/project.server.model.test.js for changes.
Watching app/tests/project.server.routes.test.js for changes.
Watching app/tests/reading.server.model.test.js for changes.
Watching app/tests/reading.server.routes.test.js for changes.
Watching app/tests/user.server.model.test.js for changes.
Watching public/modules/alerts/views/create-alert.client.view.html for changes.
Watching public/modules/bundles/views/edit-bundle.client.view.html for changes.
Watching public/modules/bundles/views/list-bundles.client.view.html for changes.
Watching public/modules/bundles/views/view-bundle.client.view.html for changes.
Watching public/modules/configurations/views/create-configuration.client.view.html for changes.
Watching public/modules/configurations/views/edit-configuration.client.view.html for changes.
Watching public/modules/configurations/views/list-configurations.client.view.html for changes.
Watching public/modules/configurations/views/view-configuration.client.view.html for changes.
Watching public/modules/core/views/admin-panel.client.view.html for changes.
Watching public/modules/core/views/checkout.client.view.html for changes.
Watching public/modules/core/views/dashboard.client.view.html for changes.
Watching public/modules/core/views/details.client.view.html for changes.
Watching public/modules/core/views/device-config.client.view.html for changes.
Watching public/modules/core/views/footer.client.view.html for changes.
Watching public/modules/core/views/header.client.view.html for changes.
Watching public/modules/core/views/home.client.view.html for changes.
Watching public/modules/core/views/project-panel.client.view.html for changes.
Watching public/modules/devices/views/create-device.client.view.html for changes.
Watching public/modules/devices/views/edit-device.client.view.html for changes.
Watching public/modules/devices/views/list-devices.client.view.html for changes.
Watching public/modules/devices/views/view-device.client.view.html for changes.
Watching public/modules/invitations/views/create-invitation.client.view.html for changes.
Watching public/modules/invitations/views/edit-invitation.client.view.html for changes.
Watching public/modules/invitations/views/list-invitations.client.view.html for changes.
Watching public/modules/invitations/views/view-invitation.client.view.html for changes.
Watching public/modules/orders/views/create-order.client.view.html for changes.
Watching public/modules/orders/views/edit-order.client.view.html for changes.
Watching public/modules/orders/views/list-orders.client.view.html for changes.
Watching public/modules/users/views/authentication/signin.client.view.html for changes.
Watching public/modules/users/views/authentication/signup.client.view.html for changes.
Watching public/modules/users/views/invitation/invitation-invalid.client.view.html for changes.
Watching public/modules/users/views/invitation/invitation-signup.client.view.html for changes.
Watching public/modules/users/views/password/forgot-password.client.view.html for changes.
Watching public/modules/alerts/alerts.client.module.js for changes.
Watching public/modules/alerts/config for changes.
Watching public/modules/alerts/controllers for changes.
Watching public/modules/alerts/services for changes.
Watching public/modules/alerts/tests for changes.
Watching public/modules/alerts/views for changes.
Watching public/modules/alerts/config/alerts.client.routes.js for changes.
Watching public/modules/alerts/controllers/alerts.client.controller.js for changes.
Watching public/modules/alerts/services/alerts.client.service.js for changes.
Watching public/modules/alerts/tests/alerts.client.controller.test.js for changes.
Watching public/modules/bundles/bundles.client.module.js for changes.
Watching public/modules/bundles/config for changes.
Watching public/modules/bundles/controllers for changes.
Watching public/modules/bundles/services for changes.
Watching public/modules/bundles/tests for changes.
Watching public/modules/bundles/views for changes.
Watching public/modules/bundles/config/bundles.client.routes.js for changes.
Watching public/modules/bundles/controllers/bundles.client.controller.js for changes.
Watching public/modules/bundles/services/bundles.client.service.js for changes.
Watching public/modules/bundles/tests/bundles.client.controller.test.js for changes.
Watching public/modules/chart/chart.client.module.js for changes.
Watching public/modules/chart/config for changes.
Watching public/modules/chart/controllers for changes.
Watching public/modules/chart/css for changes.
Watching public/modules/chart/directives for changes.
Watching public/modules/chart/services for changes.
Watching public/modules/chart/tests for changes.
Watching public/modules/chart/views for changes.
Watching public/modules/chart/directives/chart.directive.js for changes.
Watching public/modules/chart/services/d3.service.js for changes.
Watching public/modules/chart/tests/chart.directive.test.js for changes.
Watching public/modules/configurations/config/configurations.client.routes.js for changes.
Watching public/modules/configurations/configurations.client.module.js for changes.
Watching public/modules/configurations/config for changes.
Watching public/modules/configurations/controllers for changes.
Watching public/modules/configurations/services for changes.
Watching public/modules/configurations/tests for changes.
Watching public/modules/configurations/views for changes.
Watching public/modules/configurations/controllers/configurations.client.controller.js for changes.
Watching public/modules/configurations/services/configurations.client.service.js for changes.
Watching public/modules/configurations/tests/configurations.client.controller.test.js for changes.
Watching public/modules/core/config/core.client.routes.js for changes.
Watching public/modules/core/controllers/admin-panel.client.controller.js for changes.
Watching public/modules/core/controllers/checkout.client.controller.js for changes.
Watching public/modules/core/controllers/core.client.controller.js for changes.
Watching public/modules/core/controllers/dashboard.client.controller.js for changes.
Watching public/modules/core/controllers/device-config.client.controller.js for changes.
Watching public/modules/core/controllers/header.client.controller.js for changes.
Watching public/modules/core/controllers/home.client.controller.js for changes.
Watching public/modules/core/controllers/project-panel.client.controller.js for changes.
Watching public/modules/core/core.client.module.js for changes.
Watching public/modules/core/config for changes.
Watching public/modules/core/controllers for changes.
Watching public/modules/core/css for changes.
Watching public/modules/core/directives for changes.
Watching public/modules/core/img for changes.
Watching public/modules/core/services for changes.
Watching public/modules/core/tests for changes.
Watching public/modules/core/views for changes.
Watching public/modules/core/directives/chart.directive.js for changes.
Watching public/modules/core/services/device.assigner.service.js for changes.
Watching public/modules/core/services/device.encoder.service.js for changes.
Watching public/modules/core/services/device.storage.service.js for changes.
Watching public/modules/core/services/id.encryption.service.js for changes.
Watching public/modules/core/services/menus.client.service.js for changes.
Watching public/modules/core/services/projects.creator.service.js for changes.
Watching public/modules/core/services/projects.storage.service.js for changes.
Watching public/modules/core/tests/admin-panel.client.controller.test.js for changes.
Watching public/modules/core/tests/controllerTests for changes.
Watching public/modules/core/tests/directiveTests for changes.
Watching public/modules/core/tests/serviceTests for changes.
Watching public/modules/core/tests/checkout.client.controller.test.js for changes.
Watching public/modules/core/tests/dashboard.client.controller.test.js for changes.
Watching public/modules/core/tests/device-config.client.controller.test.js for changes.
Watching public/modules/core/tests/header.client.controller.test.js for changes.
Watching public/modules/core/tests/home.client.controller.test.js for changes.
Watching public/modules/core/tests/projectpanel.client.controller.test.js for changes.
Watching public/modules/core/tests/serviceTests/project.storage.service.test.js for changes.
Watching public/modules/invitations/controllers/invitations.client.controller.js for changes.
Watching public/modules/invitations/invitations.client.module.js for changes.
Watching public/modules/invitations/config for changes.
Watching public/modules/invitations/controllers for changes.
Watching public/modules/invitations/tests/invitations.client.controller.test.js for changes.
Watching public/modules/orders/config/orders.client.routes.js for changes.
Watching public/modules/orders/controllers/orders.client.controller.js for changes.
Watching public/modules/projects/config/projects.client.routes.js for changes.
Watching public/modules/projects/controllers/projects.client.controller.js for changes.
Watching public/modules/projects/projects.client.module.js for changes.
Watching public/modules/projects/config for changes.
Watching public/modules/projects/controllers for changes.
Watching public/modules/projects/services for changes.
Watching public/modules/projects/tests for changes.
Watching public/modules/projects/views for changes.
Watching public/modules/projects/services/projects.client.service.js for changes.
Watching public/modules/projects/tests/projects.client.controller.test.js for changes.
Watching public/modules/readings/config/readings.client.routes.js for changes.
Watching public/modules/readings/controllers/readings.client.controller.js for changes.
Watching public/modules/readings/tests/readings.client.controller.test.js for changes.
Watching public/modules/users/config/users.client.config.js for changes.
Watching public/modules/users/config/users.client.routes.js for changes.
Watching public/modules/users/controllers/authentication.client.controller.js for changes.
Watching public/modules/users/controllers/invitation-signup.client.controller.js for changes.
Watching public/modules/users/controllers/password.client.controller.js for changes.
Watching public/modules/users/controllers/settings.client.controller.js for changes.
Watching public/modules/users/services/authentication.client.service.js for changes.
Watching public/modules/users/services/users.client.service.js for changes.
Watching public/modules/users/tests/authentication.client.controller.test.js for changes.
Watching public/modules/users/users.client.module.js for changes.
Watching public/modules/users/config for changes.
Watching public/modules/chart/css/chart.css for changes.
Watching public/modules/core/css/admin.css for changes.
Watching public/modules/core/css/checkout.css for changes.
Watching public/modules/core/css/core.css for changes.
Watching public/modules/core/css/dashboard.css for changes.
Watching public/modules/core/css/details.css for changes.
Watching public/modules/core/css/device-config.css for changes.
Watching public/modules/core/css/font-awesome.css for changes.
Watching public/modules/core/css/footer.css for changes.
Watching public/modules/core/css/header.css for changes.
Watching public/modules/core/css/home.css for changes.
Watching public/modules/core/css/icomoon.css for changes.
Watching public/modules/core/css/overrides.css for changes.
Watching public/modules/core/css/project-panel.css for changes.
Watching public/modules/users/css/users.css for changes.
无论我在浏览器中做什么,这个冗长的输出都会停在这里,之后什么都不做。
该应用程序实际上正在运行(在 localhost:3000 上)并且 livereload 和类似的东西似乎正在运行,但我在终端输出中什么也没看到。这使得调试和弄清楚我的应用程序中正在加载/未加载的内容变得非常困难。
关于发生了什么的任何想法?
** 作为旁注,我最近必须重新安装 Node 和 npm,不确定是否与它有关
提前致谢