当从主机编辑文件时,虚拟机中的Nodemon看不到更改

Nodemon in VM does not see changes when file edited from host machine

本文关键字:Nodemon 看不到 虚拟机 主机 编辑文件      更新时间:2023-09-26

我有一个node应用程序,我使用nodemon在虚拟机(Virtualbox、Vagrant、Ubuntu)内运行,用于开发目的。

这些文件位于vagrant的共享文件夹中。

当我更改虚拟机内的应用程序js文件时,nodemon会重新启动节点应用程序。但当我从主机(Max OS X Yosemite)更改相同的文件时,应用程序不会重新启动。

在类似的情况下,当主机是Windows 10时,它工作得很好。

我通过配置的Grunt启动nodemon

module.exports = function (grunt) {
    var cfg = {
        pkg: grunt.file.readJSON('package.json'),
        nodemon: {
            dev: {
                script: 'src/server.js'
            },
            options: {
                nodeArgs: ['--harmony'],
                ext: 'js,json,hbs',
                ignore: [
                    'public/**',
                    'node_modules/**',
                    '.git/**'
                ]
            }
        }
    };
    grunt.initConfig(cfg);
    grunt.loadNpmTasks('grunt-nodemon');
    grunt.registerTask('default', ['nodemon']);
};

或直接nodemon ./src/server.js localhost 3000

我错过了什么?

尝试在options部分中为nodemonGrunt的配置参数legacyWatch: true使用参数-L

详细信息可以在这里找到。