简体   繁体   中英

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

I'm currently learning Node.JS and want to improve my development speed with Grunt. I've installed the "grunt-cli" globally and also "grunt-nodemon" as a development resource locally through NPM. The goal is that Node.JS restarts, whenever a JavaScript file changed.

Here's what I get in the Console:

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.

Here's my 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']);
}; 

The console is pointing at the same directory where as the gruntfile.js is.

If you have any idea, let me know. Thanks!

Line 1 of your code is

mode.exports

it should be

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

Hence the error

ReferenceError: mode is not defined

check the typo. Happy coding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM