TypeError [ERR_INVALID_ARG_TYPE]:“listener”参数必须为 function 类型。收到 App 的实例

TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received an instance of App

提问人:blueprint11487 提问时间:5/25/2023 更新时间:5/25/2023 访问量:176

问:

我几乎是一个新手,正在努力学习,但我似乎在试图让我的 nodejs slack/bolt 服务器运行时遇到了问题。每当我尝试时,我都会收到以下错误:sudo node app.js

node:internal/validators:421
    throw new ERR_INVALID_ARG_TYPE(name, 'Function', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received an instance of App
    at checkListener (node:events:266:3)
    at _addListener (node:events:546:3)
    at Server.addListener (node:events:605:10)
    at new Server (node:https:79:10)
    at Object.createServer (node:https:112:10)
    at Object.<anonymous> (/home/opc/slack-bolt-app/app.js:24:25)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12) {
  code: 'ERR_INVALID_ARG_TYPE'
}

下面是我的应用.js代码。我搞砸了,但我不确定有多糟糕以及如何纠正。

require('dotenv').config()
const https = require('https')
const path = require('path')
const fs = require('fs')
const { App } = require('@slack/bolt');

// Initializes your app with your bot token and signing secret
const app = new App({
  token: process.env.SLACK_BOT_TOKEN,
  signingSecret: process.env.SLACK_SIGNING_SECRET,
      endpoints: {
     events: '/slack/events',
     commands: '/slack/commands'
   }
});

//(async () => {
  // Start your app
//  await app.start(process.env.PORT || 3000);

//  console.log('⚡️ Bolt app is running!');
//})

const sslServer = https.createServer(

{
    key: fs.readFileSync(path.join(__dirname, 'cert', 'key.pem')),
    cert: fs.readFileSync(path.join(__dirname, 'cert', 'cert.pem')),
},
    app
)

sslServer.listen(3000, () => console.log('Secure serer on port 3000'))


();

到目前为止,我已经尝试从“异步”注释到“console.log”,但没有运气。任何帮助都非常感谢!

节点.js SSL 事件 松弛

评论


答: 暂无答案