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.
Creo que se olvidó de guardar el archivo router.mjs porque cometí el mismo error y obtuve este error :)