Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

130
Visualizações
I get an uncaught error after running my code

I am working on a project and every time node run my code the browser console gives me this :

Uncaught TypeError: Failed to resolve module specifier "express". Relative references must start with either "/", "./", or "../".

It says this line gives me the error:

<!DOCTYPE HTML>

I don't know why do I keep getting this error. Please help. Thank you.

And I have npm installed 'express', 'node-fetch' and 'esm'.

This is my main.js file:

import express from 'express';

import fetch from 'node-fetch';

const { clientID, clientSecret, port } = require('./config.json');
const app = express();

app.use(express.static('public'));

app.get('/', async ({ query }, response) => {
    const { code } = query;

    if (code) {
        try {
            const oauthResult = await fetch('https://discord.com/api/oauth2/token', {
                method  : 'POST',
                body    : new URLSearchParams({
                    client_id     : clientID,
                    client_secret : clientSecret,
                    code,
                    grant_type    : 'authorization_code',
                    redirect_uri  : `http://localhost:${port}`,
                    scope         : 'identify'
                }),
                headers : {
                    'Content-Type' : 'application/x-www-form-urlencoded'
                }
            });

            const oauthData = await oauthResult.json();

            const userResult = await fetch('https://discord.com/api/users/@me', {
                headers : {
                    authorization : `${oauthData.token_type} ${oauthData.access_token}`
                }
            });

            console.log(await userResult.json());
        } catch (error) {
            // NOTE: An unauthorized token will not throw an error;
            // it will return a 401 Unauthorized response in the try block above
            console.error(error);
        }
    }

    return response.sendFile('index.html', { root: '.' });
});

app.listen(port, () => console.log(`App listening at http://localhost:${port}`));

And this is my start.js:

// file start.js
require = require('esm')(module /*, options*/);
module.exports = require('./main');
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

the first thing you need to do is, install one bundler (parcel), then you need develop your package.json script which serve from parcel

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda