• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

103
Views
Recibo un error no detectado después de ejecutar mi código

Estoy trabajando en un proyecto y cada vez que el nodo ejecuta mi código, la consola del navegador me da esto:

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

Dice que esta línea me da el error:

 <!DOCTYPE HTML>

No sé por qué sigo recibiendo este error. Por favor ayuda. Gracias.

Y tengo npm instalado 'express', 'node-fetch' y 'esm'.

Este es mi archivo main.js:

 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}`));

Y este es mi start.js:

 // file start.js require = require('esm')(module /*, options*/); module.exports = require('./main');
over 3 years ago · Santiago Trujillo
1 answers
Answer question

0

lo primero que debe hacer es instalar un paquete (paquete), luego debe desarrollar su secuencia de comandos package.json que sirve desde el paquete

over 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error