Error import * as http from "http"

i had this error:

import * as http from “http”
SyntaxError: Unexpected token *
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
:lady_beetle: The debugger could not be started. See Search results for debugger - Glitch Support

i think all is right and i already have type:“module”, in package.json

That is valid js. From

import * as name from "module-name";

@kyulakyu what node version are you using? If it’s v13.2.0 or less, you need to use the --experimental-modules flag.

1 Like

im using 15.12.0

here is my package

“name”: “kyu-bot”,
“version”: “0.0.1”,
“description”: “Botcito bonito”,
“main”: “node server.js”,
“author”: “Kyu”,
“type”: “module”,
“esModuleInterop”: true,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”,
“start”: “node server.js”
“dependencies”: {
“express”: “^4.17.1”,
“discord.js”: “^12.5.2”,
“http”: “^0.0.0”,
“twitch”: “^4.5.5”,
“twitch-auth”: “^4.5.5”,
“twitch-eventsub-ngrok”: “^4.5.5”,
“axios”: “^0.21.1”,
“twitch-eventsub”: “^4.5.5”,
“npm”: “^7.8.0”,
“ts-node”: “^9.1.1”,
“node”: “^15.12.0”
“engines”: {
“node”: “10.x”
“repository”: {
“url”: “.”
“license”: “MIT”,
“keywords”: [

It looks like you need v13.2.0 for import. Can you use this instead?

var http = require("http")

Hope this helps :slight_smile:

1 Like

i try, and the new error are:
import * as express from “express”

my code start

var http = require(“http”)
import * as express from “express”
const app = express();
import { config } from “./config.js”;
import * as eventsub from “./eventsub”
let prefix = config.prefix;


app.get("/", function (request, response) {
response.sendFile(__dirname + ‘/views/index.html’);

app.get("/", (request, response) => {


setInterval(() => {
}, 280000);

const Discord = require(‘discord.js’);
const client = new Discord.Client({
ws: { intents: 32767 } }

const http = require(‘http’);
const express = require(‘express’);
const app = express();

setInterval(() => {
}, 280000);

const { Client, Collection, MessageEmbed } = require(‘discord.js’),
const client = new Client({
partials: [‘MESSAGE’, ‘CHANNEL’, ‘REACTION’],
fetchAllMembers: true


Oh hold up, It seems like it’s Uptime code for glitch. But hey! Please read this post since they’re blocked & illegal on glitch now!

Oh I didn’t know, is there another way? I currently use heroku to have my bot active, which I can use instead of

setInterval (() => {
http.get (http: // $ {process.env.PROJECT_DOMAIN} /);
}, 280000);


work with const express = require(express);
but now i had problems with
import { config } from “./config.js”;

my config.js are:

export const Config = {
“log_channel_id”: “aaaa”,
“client_id”: “aaaa”,
“client_secret”: “aaaaa”,
“streamer_name”: “aaaa”,
“listener_secret”: “xyzxyzxyz”
it’s really getting heavy on me

var config = require("./config.json")

will do

1 Like

thx! work as well.
now i had the problem with:

export class DiscordBot {

I think it is not what it is called since elsewhere I am calling it this way:

import { DiscordBot } from “./server.js”

I really appreciate your help guys