Closed
Description
I tried to run strapi inside nginx unit. The startup of strapi doesn't work because of the following error:
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received an instance of Object
at checkListener (node:events:270:3)
at _addListener (node:events:550:3)
at Server.addListener (node:events:609:10)
at new Server (/usr/local/lib/node_modules/unit-http/http_server.js:426:14)
at Object.createServer (/usr/local/lib/node_modules/unit-http/http.js:15:12)
at Module.createHTTPServer (/var/www/node_modules/@strapi/strapi/dist/services/server/http-server.js:16:40)
at Module.createServer (/var/www/node_modules/@strapi/strapi/dist/services/server/index.js:26:35)
at new Strapi (/var/www/node_modules/@strapi/strapi/dist/Strapi.js:130:27)
at initFn (/var/www/node_modules/@strapi/strapi/dist/Strapi.js:466:18)
at Object.<anonymous> (/var/www/index.js:2:1) {
code: 'ERR_INVALID_ARG_TYPE'
}
Strapi uses options
with the http.createServer
function as seen here in the source code. The node signature of the createServer
function looks like this: http.createServer([options][, requestListener])
. Looking at the http
module inside the unit-http
package the createServer
function is missing the options argument.
Can this be solved somehow? How could strapi be started otherwise within nginx unit?
Nginx Unit has the following config.json:
{
"listeners": {
"*:1337": {
"pass": "routes/main"
}
},
"routes": {
"main": [
{
"action": {
"pass": "applications/app"
}
}
]
},
"applications": {
"app": {
"type": "external",
"working_directory": "/var/www/",
"executable": "/usr/bin/env",
"arguments": [
"node",
"--loader",
"unit-http/loader.mjs",
"--require",
"unit-http/loader",
"index.js"
]
}
}
}