gpt4 book ai didi

node.js - Grunt 不会加载 Node 服务器

转载 作者:太空宇宙 更新时间:2023-11-03 22:40:49 24 4
gpt4 key购买 nike

我的gruntfile.js是:

'use strict';

module.exports = function(grunt) {
// Project Configuration
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
jade: {
files: ['app/views/**'],
options: {
livereload: true,
},
},
js: {
files: ['gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**', 'test/**/*.js'],
tasks: ['jshint'],
options: {
livereload: true,
},
},
html: {
files: ['public/views/**'],
options: {
livereload: true,
},
},
css: {
files: ['public/css/**'],
options: {
livereload: true
}
}
},
jshint: {
all: {
src: ['gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**', 'test/**/*.js'],
options: {
jshintrc: true
}
}
},
nodemon: {
dev: {
options: {
file: 'server.js',
args: [],
ignoredFiles: ['public/**'],
watchedExtensions: ['js'],
nodeArgs: ['--debug'],
delayTime: 1,
env: {
PORT: 3000
},
cwd: __dirname
}
}
},
concurrent: {
tasks: ['nodemon', 'watch'],
options: {
logConcurrentOutput: true
}
},
mochaTest: {
options: {
reporter: 'spec',
require: 'server.js'
},
src: ['test/mocha/**/*.js']
},
env: {
test: {
NODE_ENV: 'test'
}
},
karma: {
unit: {
configFile: 'test/karma/karma.conf.js'
}
}
});

//Load NPM tasks
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-env');

//Making grunt default to force in order not to break the project.
grunt.option('force', true);

//Default task(s).
grunt.registerTask('default', ['jshint', 'concurrent']);

//Test task.
grunt.registerTask('test', ['env:test', 'mochaTest', 'karma:unit']);
};

当我输入grunt时,我得到:

$ grunt
Running "jshint:all" (jshint) task
>> 69 files lint free.

Running "concurrent:tasks" (concurrent) task
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...

通常它会显示Express 在端口 3000 上启动,但突然就不是了。不知道发生了什么事。有什么想法吗?

当使用 -v 标志运行时,我得到:

Running tasks: nodemon

Running "nodemon" task

Running "nodemon:dev" (nodemon) task
Verifying property nodemon.dev exists in config...OK
File: [no files]
Options: file="server.js", args=[], ignoredFiles=["public/**"], watchedExtensions=["js"], nodeArgs=["--debug"], delayTime=1, env={"PORT":3000}, cwd="/Users/shamoon/Sites/blocksearcher"
Loading "env.js" tasks...OK
+ env
Loading "gruntfile.js" tasks...OK
+ default, test

Running tasks: watch

Running "watch" task
Waiting...Verifying property watch exists in config...OK
Verifying property watch.jade.files exists in config...OK
Verifying property watch.js.files exists in config...OK
Verifying property watch.html.files exists in config...OK
Verifying property watch.css.files exists in config...OK
Live reload server started on port: 35729


Watching app/views for changes.
Watching app/views/includes for changes.
...

最佳答案

查看 grunt-nodemon 的变更日志:https://github.com/ChrisWren/grunt-nodemon#changelog .

您最近必须更新依赖项,并且 grunt-nodemon 更改了一些属性。

- file is now script
- ignoredFiles -> ignore
- watchedFolders -> watch
- watchedExtensions -> ext

关于node.js - Grunt 不会加载 Node 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21234304/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com