I'm making some optimation on nextjs project and need to has type: 'module' on thepackage.json file. But then got the error
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: my_path/next.config.js require() of ES modules is not supported.
Seem next.config.js is not support ESM yet. The issue already discussed here: https://github.com/vercel/next.js/issues/9607 but I can find a solution yet. Any help guys?
I'm using: node v12.17.0 next 11.1.0
And here is my next.config.js
import withLess from '@zeit/next-less'
const nextConfig = {
target: 'serverless',
productionBrowserSourceMaps: true,
webpack5: true,
onDemandEntries: {
maxInactiveAge: 1000 * 60 * 60,
pagesBufferLength: 5
},
lessLoaderOptions: {
javascriptEnabled: true
},
trailingSlash: false,
}
export default withLess(nextConfig)
My package.json file
{
"type": "module"
...
}
from Support ESM in next.config.js
No comments:
Post a Comment