XenicsMadnessC
XenicsMadnessC

Reputation: 1

express-js type error , app.listen is not a function

My current code looks like this.

const express = require("express");
const app = express;

app.listen(3000,  () => {
  console.log("project is running!");
})

app.get("/", (req, res) => {
  res.send("Hello World!");
})

const Discord = require("Discord.js")
const client = new Discord.Client({intents: ["GUILDS", "GUILD_MESSSAGES"]});

client.on("message", message => {
  if(message.content === "wanna hear a joke") {
    message.channel.send("Shut up.")
  }
})

client.login(process.env.token);

and when i went to test it, it says TypeError: app.listen is not a function

it should've work but it keeps doing it

Upvotes: 0

Views: 197

Answers (1)

Paul-Marie
Paul-Marie

Reputation: 1053

Be brave and don't give up, you only need to add () to express on the 2nd line like this:

Before:

const app = express;

After:

const app = express();

Upvotes: 1

Related Questions