我在运行这段代码时得到了这个错误。
let { controllerUser } = require('./router')
ReferenceError: require is not defined in ES module scope, you can use import instead This file is being treated as an ES module because it has a '.js' file extension and 'C:Projectfirst-projectpackage.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
在package.json中使用type module在node js中路由
如果您有"type"; "在package.json,尝试使用import {controllerUser} from "./router.js">
你不能把es6模块和commonJs模块混在一起