app.js:358 Uncaught ReferenceError: require is not defined
at eval (index.mjs:4:30)
at Module../node_modules/@element-plus/icons-vue/dist/es/index.mjs (chunk-vendors.js:9072:1)
at webpack_require (app.js:355:33)
at fn (app.js:600:21)
at eval (icon.js:7:16)
at Object../node_modules/element-plus/lib/utils/vue/icon.js (chunk-vendors.js:7646:1)
at webpack_require (app.js:355:33)
at fn (app.js:600:21)
at Object../node_modules/element-plus/lib/utils/vue/index.js (chunk-vendors.js:7665:12)
at webpack_require (app.js:355:33)
解决方案:
- 1. 在
.env.development
文件中不在需要配置VUE_CLI_BABEL_TRANSPILE_MODULES = true
,删除即可。
2. 在命令行执行 npm install babel-plugin-dynamic-import-node -S -D
3. 在babel.config.js
中添加插件
module.exports = {
presets: ['@vue/cli-plugin-babel/preset'],
env: {
development: {
plugins: ['dynamic-import-node']
}
}
}