failed to load config from Elearn-vue3vue-projectviteconfigjs error when starting dev server Error [ERR_REQUIRE_ESM] require of ES Module Elearn-vue3vue-projectnode_modulesvite-plugin-aliasdis
This error message suggests that there is an issue with the configuration file for Vite, specifically with the use of the vite-plugin-alias package. The error message recommends changing the require statement in the configuration file to a dynamic import() statement, which is available in all CommonJS modules.
To fix this issue, you can try modifying the require statement in your vite.config.js file to use a dynamic import() statement instead. For example, instead of:
const { defineConfig } = require('vite') const alias = require('vite-plugin-alias')
module.exports = defineConfig({ plugins: [ alias({ entries: { '@': './src' } }) ] })
You could try:
const { defineConfig } = require('vite')
module.exports = defineConfig({ plugins: [ import('vite-plugin-alias').then(({ default: alias }) => alias({ entries: { '@': './src' } })) ] })
This should allow Vite to properly load the configuration file and start the development server.
原文地址: https://www.cveoy.top/t/topic/bREA 著作权归作者所有。请勿转载和采集!