简体   繁体   中英

Deploy Node-RED to Heroku

I found out the files included in the Github repo that used to connect to the Heroku server and substituted with my own package.json , flow.json , repo link in app.json . After deploying, I tried opening app and received an error from the logs window of Heroku CLI as below:

2021-04-13T10:22:01.693823+00:00 heroku[web.1]: Starting process with command `node --max-old-space-size=384 node_modules/node-red/red.js --settings ./settings.js --userDir ./`
2021-04-13T10:22:05.304911+00:00 heroku[web.1]: Process exited with status 1
2021-04-13T10:22:05.411606+00:00 heroku[web.1]: State changed from starting to crashed
2021-04-13T10:22:05.185490+00:00 app[web.1]: throw err;
2021-04-13T10:22:05.185491+00:00 app[web.1]: ^
2021-04-13T10:22:05.185491+00:00 app[web.1]:
2021-04-13T10:22:05.185492+00:00 app[web.1]: Error: Cannot find 
module '/app/node_modules/node-red/red.js'
2021-04-13T10:22:05.185492+00:00 app[web.1]: at 
Function.Module._resolveFilename 
(internal/modules/cjs/loader.js:880:15)
2021-04-13T10:22:05.185492+00:00 app[web.1]: at 
Function.Module._load (internal/modules/cjs/loader.js:725:27)
2021-04-13T10:22:05.185493+00:00 app[web.1]: at 
Function.executeUserEntryPoint [as runMain] 
(internal/modules/run_main.js:72:12)
2021-04-13T10:22:05.185494+00:00 app[web.1]: at 
internal/main/run_main_module.js:17:47 {
2021-04-13T10:22:05.185494+00:00 app[web.1]: code: 
'MODULE_NOT_FOUND',
2021-04-13T10:22:05.185495+00:00 app[web.1]: requireStack: []
2021-04-13T10:22:05.185495+00:00 app[web.1]: }

My Github repo link Hope to get your help. Thanks.

You have removed Node-RED from the package.json , so since it's not installed it won't start.

{
    "name": "node-red-project",
    "description": "A Node-RED Project",
    "version": "0.0.1",
    "dependencies": {
        "node-red-contrib-alarm": "~1.2.5",
        "node-red-contrib-component-dashboard": "0.0.4",
        "node-red-contrib-components": "~0.1.8",
        "node-red-contrib-firebase": "~1.1.1",
        "node-red-contrib-influxdb": "~0.5.1",
        "node-red-contrib-mqtt-broker": "~0.2.4",
        "node-red-contrib-remote": "~1.1.3",
        "node-red-contrib-ttn": "~2.0.5",
        "node-red-contrib-ui-svg": "~2.2.1",
        "node-red-contrib-users": "~0.1.9",
        "node-red-dashboard": "~2.14.0",
        "node-red-node-ui-table": "~0.3.10"
    }
}

If you want to add extra nodes, you need to add these to the list of dependencies in the existing package.json not just replace them.

{
    "name": "nodered-heroku",
    "version": "0.0.7",
    "dependencies": {
        "when": "3.7.8",
        "nano": "8.2.2",
        "feedparser":"2.2.10",
        "node-red-dashboard":"2.23.3",
        "redis":"3.0.2",
        "node-red": "1.1.3",
        "node-red-node-tail": "0.1.1",
        "node-red-contrib-aedes": "0.3.6",
        "node-red-contrib-blynk-ws": "1.0.3",
        "node-red-node-email": "1.7.9",
        "node-red-node-ui-list": "0.3.1",
        "node-red-contrib-telegrambot": "8.4.0",
        "node-red-contrib-alarm": "~1.2.5",
        "node-red-contrib-component-dashboard": "0.0.4",
        "node-red-contrib-components": "~0.1.8",
        "node-red-contrib-firebase": "~1.1.1",
        "node-red-contrib-influxdb": "~0.5.1",
        "node-red-contrib-mqtt-broker": "~0.2.4",
        "node-red-contrib-remote": "~1.1.3",
        "node-red-contrib-ttn": "~2.0.5",
        "node-red-contrib-ui-svg": "~2.2.1",
        "node-red-contrib-users": "~0.1.9",
        "node-red-node-ui-table": "~0.3.10"
    }
}

I would also suggest you use the latest version of Node-RED (1.3.1 at time of posting) as 1.1.3 is VERY OLD

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