gpt4 book ai didi

javascript - Node.JS/Grunt-Nodemon : ReferenceError: mode is not defined

转载 作者:行者123 更新时间:2023-11-28 19:04:10 25 4
gpt4 key购买 nike

我目前正在学习 Node.JS,希望通过 Grunt 提高我的开发速度。我已经在全局范围内安装了“grunt-cli”,并且还通过 NPM 在本地安装了“grunt-nodemon”作为开发资源。目标是只要 JavaScript 文件发生更改,Node.JS 就会重新启动。

这是我在控制台中得到的内容:

D:\Projects\NodeJS\Web\Board\>grunt
Loading "gruntfile.js" tasks...ERROR
>> ReferenceError: mode is not defined
Warning: Task "default" not found. Use --force to continue.

Aborted due to warnings.

这是我的 gruntfile.js:

//gruntfile.js
mode.exports = function (grunt) {
grunt.initConfig({
nodemon: {
all: {
script: 'server.js',
options: {
watchedExtensions: ['js']
}
}
},
});
grunt.loadNpmTasks('grunt-nodemon');
grunt.registerTask('default', ['nodemon']);
};

控制台指向 gruntfile.js 所在的同一目录。

如果您有任何想法,请告诉我。谢谢!

最佳答案

代码的第一行是

mode.exports

应该是

module.exports   // change mode to module. Its a typo in your code

因此出现错误

ReferenceError: mode is not defined

检查拼写错误。快乐编码。

关于javascript - Node.JS/Grunt-Nodemon : ReferenceError: mode is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32004142/

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