Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

388
Views
El módulo solicitado no proporciona una exportación denominada predeterminada a través de enrutamiento expreso

Necesito ayuda para encontrar exactamente lo que me falta aquí.

Si ayuda, mi aplicación está en node.js (16.13.1) usando la última versión de express, así como un proxy inverso nginx.

app.mjs

 import router from './assets/js/router.mjs'; //Imports our routes import express from 'express'; const expressapp = express(); //Creates the application with express const moduleURL = new URL(import.meta.url); //Creates a new URL to use for the current directory name const __dirname = path.dirname(moduleURL.pathname); //Creates the directory name and attaches it to the __dirname constant. //Middleware //Instructions for the app to use body parser & JSON goes here expressapp.use('/subscribe', router); //Use the subscribe route expressapp.use(express.static(__dirname, {index: 'index.html'})); //Tells the app to use the current path, with the index being index.html expressapp.post('/subscribe', (req, res) => { //post request stuff goes here }

enrutador.mjs

 import express from 'express'; var router = express.Router(); // middleware that is specific to this router router.use(function timeLog (req, res, next) { console.log('Time: ', Date.now()) next() }) // define the home page route router.get('/', function (req, res) { res.send('Gaming Galaxy Landing Page') }) // define the subscribe route router.get('/subscribe', function (req, res) { res.send('Subscribe route') }) export default router;

Error

 import router from './assets/js/router.mjs'; //Imports our routes ^^^^^^ SyntaxError: The requested module './assets/js/router.mjs' does not provide an export named 'default' at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21) at async ModuleJob.run (node:internal/modules/esm/module_job:181:5) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:281:24) at async loadESM (node:internal/process/esm_loader:88:5) at async handleMainPromise (node:internal/modules/run_main:65:12)

Como alguien que es algo nuevo en esto, realmente no sé qué está mal cuando definí específicamente una exportación predeterminada en mi enrutador. Si alguien pudiera ayudarme a saber qué está pasando exactamente aquí, sería muy apreciado.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que se olvidó de guardar el archivo router.mjs porque cometí el mismo error y obtuve este error :)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!