import routes from "./src/router/routes";
module.exports = {
// routes
}
这里不能使用es6模块,报错:
import routes from "./src/router/routes";
^^^^^^
SyntaxError: Unexpected identifier
require 也不起作用,因为路由是 ES6 模块(有 import 语句)
const routes = require("./src/router/routes");
最佳答案
您必须在 NodeJs 中启用 ES6 模块。
检查此链接是否启用:
- https://nodejs.org/api/esm.html
- https://blog.logrocket.com/es-modules-in-node-js-12-from-experimental-to-release/
注意:此资源是实验性的
关于vue.js - 如何在 vue.config.js 中使用 ES6?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63001659/