Refresh a running node-red instance (after npm install <myNode>)

The Title says all;)

i run a node-red instance. Parallel i play around developing a node to get confident with it.

and i dont want do to allways.. kill node-red => install my node => start node-red..

is there node install on-fly methode!?:wink:

Thanks a lot folks:=

I don't believe it's possible.

You could run a seperate instance of Node-red for development.
Use a different base folder and port number.
Or on a different computer, such as a Raspberry Pi.

ok, but how can i install node vua npm no fily, and refredh the running node-red instanceĀ°!?

Hi, the way I do it is to run my development version of Node-RED under PM2. I then configure PM2 with a series of watch folders and when it detects a changed file in one of those folders, it automatically restarts Node-RED.

What that doesn't do is refresh the Editor though. If you've made changes to your node's HTML file, after Node-RED restarts, you need to refresh the editor window as well.

I install Node-RED into a local folder rather than globally and I set the userDir to be a sub-folder of that. (see my alternate installer on GitHub). This makes it easy to have a package.json file containing scripts so that you can simply do npm start, npm restart, etc. It also means that you can put the ecosystem.config.js file for PM2 in the same folder.

Here is my current config file for PM2:

// PM2 Configuration for running Node-RED test/dev

module.exports = {
    apps : [{
        name: 'Node-RED',
        script: 'C:/src/nr/node_modules/node-red/red.js',

        // Options reference: https://pm2.keymetrics.io/docs/usage/application-declaration/
        args: '--userDir ./data',
        // instances: 1,
        // autorestart: true,
        watch: [
            'C:/src/nr/data/settings.js',
            'C:/src/nr/data/projects/uib1/uibuilder/.config/security.js',
            'C:/src/node-red-contrib-infocache/nodes/',
            'C:/src/node-red-contrib-uibuilder/nodes/',
            'C:/src/node-red-contrib-pouchdb/nodes/',
            'C:/src/node-red-contrib-jktesting/nodes/',
            'C:/src/node-red-contrib-events/nodes/',
            'C:/src/node-red-contrib-drayton-wiser/nodes/',
            'C:/src/node-red-experimental-nodes/nodes/',
            'C:/src/node-red-experimental-nodes/package.json',
            'C:/src/nr-test/nodes/',
            'C:/src/nr/data/settings.js',
            'C:/src/nr/node_modules/node-red/red.js',
            'C:/src/nr/node_modules/@node-red/runtime/lib/nodes/index.js',
            //'C:/src/nr-source/ti-theme/style.css'
        ],
        ignore_watch: [
            'C:/src/nr/node_modules',
            'C:/src/nr/data/node_modules',
            'C:/src/nr/.vscode',
            'C:/src/node-red-contrib-uibuilder/front-end/dist',
            'C:/src/node-red-contrib-uibuilder/nodes/icons',
            'C:/src/node-red-contrib-uibuilder/nodes/.*\.html',
            'C:/src/node-red-contrib-uibuilder/front-end/src',
            'C:/src/node-red-contrib-uibuilder/templates',
            'C:/src/node-red-contrib-uibuilder/node-src',
            'C:/src/node-red-contrib-events/nodes/.*\.html',
            'C:/src/node-red-contrib-drayton-wiser/nodes/.*\.html',
            'C:/src/node-red-contrib-drayton-wiser/src/.*',
            'C:/src/node-red-experimental-nodes/nodes/.*\.html',
        ],
        // max_memory_restart: '1G',
        env: {
            NODE_ENV: 'development',
            TI_ENV: 'debug',
            //DEBUG: 'express:paths,express:router',
        },
        env_production: {
            NODE_ENV: 'production'
        },
        //shutdown_with_message: true,
        //kill_timeout : 3000,
        //listen_timeout: 10000,
        error_file: 'C:/src/nr/logout.log',  // default: $HOME/.pm2/logs/XXXerr.log
        out_file: 'C:/src/nr/logout.log',      // default: $HOME/.pm2/logs/XXXout.log
        pid_file: 'C:/src/nr/nrtest.pid',      // default: $HOME/.pm2/pid/app-pm_id.pid
        combine_logs: true,
        merge_logs: true,
        //log_date_format: 'DD HH:mm',                    // default: 'YYYY-MM-DD HH:mm Z'
    }],
}

And the package.json scripts:

  "scripts": {
    "start": "pm2 start ecosystem.config.js && pm2 logs",
    "restart": "pm2 restart Node-RED --update-env && pm2 logs",