I use express to start Node-red, it's run well use cmd by command "node index.js". But when i use "npm pkg" to pack into the app,and run the app it show [warn] [node-red/httprequest] TypeError: Invalid host defined options, and use wmi node [error] [wmi:Windows or macOS?] Failed to load module : TypeError: Invalid host defined options. What can i do for it?
this is my index.js:
var http = require('http');
var express = require("express");
var RED = require("node-red");
// Create an Express app
var app = express();
// Add a simple route for static content served from 'public'
app.use("/",express.static("public"));
// Create a server
var server = http.createServer(app);
// Create the settings object - see default settings.js file for other options
var nrSettings = require("./settings.js"); // Node-Red settings file
// Initialise the runtime with a server and settings
RED.init(server,nrSettings);
// Serve the editor UI from /httpAdminRoot
app.use(nrSettings.httpAdminRoot, RED.httpAdmin);
// Serve the http nodes from /
app.use(nrSettings.httpNodeRoot, RED.httpNode);
server.listen(8000);
// Start the runtime
RED.start();
E:\project\>pkg -t win -C GZip package.json
> pkg@5.8.1
compression: GZip
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\SmartFactoryNode\node_modules\form-data-encoder\lib\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\SmartFactoryNode\node_modules\lowercase-keys\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\SmartFactoryNode\node_modules\p-cancelable\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\SmartFactoryNode\node_modules\responselike\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\SmartFactoryNode\node_modules\mimic-response\index.js
> Warning Failed to make bytecode node18-x64 for file C:\snapshot\SmartFactoryNode\node_modules\normalize-url\index.js
17 Oct 22:14:16 - [info] Node-RED version: v3.1.0
17 Oct 22:14:16 - [info] Node.js version: v18.5.0
17 Oct 22:14:16 - [info] Windows_NT 10.0.19044 x64 LE
17 Oct 22:14:17 - [info] Loading palette nodes
17 Oct 22:14:18 - [info] Dashboard version 3.6.0 started at /ui
17 Oct 22:14:18 - [warn] ------------------------------------------------------
17 Oct 22:14:18 - [warn] [node-red/httprequest] TypeError: Invalid host defined options
17 Oct 22:14:18 - [warn] ------------------------------------------------------
17 Oct 22:14:18 - [info] Context store : 'default' [module=memory]
17 Oct 22:14:18 - [info] User directory : E:/project/data/.nodered/
17 Oct 22:14:18 - [warn] Projects disabled : editorTheme.projects.enabled=false
17 Oct 22:14:18 - [info] Flows file : E:\project\data\.nodered\myflows.json
17 Oct 22:14:19 - [info] Starting flows
17 Oct 22:14:19 - [error] [wmi:Windows or macOS?] Failed to load module : TypeError: Invalid host defined options
17 Oct 22:14:19 - [error] [wmi:Windows or macOS?] Function node failed to load external modules
17 Oct 22:14:19 - [error] [wmi:Windows or macOS?] Failed to load module : TypeError: Invalid host defined options
17 Oct 22:14:19 - [error] [wmi:Windows or macOS?] Function node failed to load external modules
17 Oct 22:14:19 - [info] Started flows
because if i remove the "scripts": ["node_modules/@node-red/nodes/core/network/21-httprequest.js"] and pkg and run,it show error:
17 Oct 23:08:07 - [info] Node-RED version: v3.1.0
17 Oct 23:08:07 - [info] Node.js version: v18.5.0
17 Oct 23:08:07 - [info] Windows_NT 10.0.19044 x64 LE
17 Oct 23:08:08 - [info] Loading palette nodes
17 Oct 23:08:10 - [info] Dashboard version 3.6.0 started at /ui
17 Oct 23:08:10 - [warn] ------------------------------------------------------
17 Oct 23:08:10 - [warn] [node-red/httprequest] Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'got' imported from C:\snapshot\SmartFactoryNode\node_modules\@node-red\nodes\core\network\21-httprequest.js
Did you mean to import got/dist/source/index.js?
17 Oct 23:08:10 - [warn] ------------------------------------------------------
17 Oct 23:08:10 - [info] Context store : 'default' [module=memory]
17 Oct 23:08:10 - [info] User directory : E:/project/SmartFactoryNode/data/.nodered/
17 Oct 23:08:10 - [warn] Projects disabled : editorTheme.projects.enabled=false
17 Oct 23:08:10 - [info] Flows file : E:\project\SmartFactoryNode\data\.nodered\myflows.json
17 Oct 23:08:10 - [info] Starting flows
17 Oct 23:08:10 - [error] [wmi:Windows or macOS?] Failed to load module : TypeError: Invalid host defined options
17 Oct 23:08:10 - [error] [wmi:Windows or macOS?] Function node failed to load external modules
17 Oct 23:08:10 - [error] [wmi:Windows or macOS?] Failed to load module : TypeError: Invalid host defined options
17 Oct 23:08:10 - [error] [wmi:Windows or macOS?] Function node failed to load external modules
[node-red/httprequest] TypeError: Invalid host defined options
Not sure where to look currently - I think the got library is playing games with pkg - if I get more time, I will research, others may chip if otherwise
yes ,I have try your script which you link to, but also saw belong:
18 Oct 00:35:04 - [warn] [node-red/httprequest] Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'got' imported from C:\snapshot\SmartFactoryNode\node_modules\@node-red\nodes\core\network\21-httprequest.js
Did you mean to import got/dist/source/index.js?