I am working in the next.js new version 13.4.1 App route , I made a api route.js I want to get something but I getting error ,
- error ./node_modules/bson/lib/bson.mjs
Module parse failed: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
Error: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
Import trace for requested module:
when I installed next.js ever after that next.config.js file was empty
. if I tried write some code inside the next.config.js then i getting anther error
warn Invalid next.config.js options detected:
- warn The root value has an unexpected property, topLevelAwait, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, configOrigin, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, modularizeImports, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, skipMiddlewareUrlNormalize, skipTrailingSlashRedirect, staticPageGenerationTimeout, swcMinify, target, trailingSlash, transpilePackages, typescript, useFileSystemPublicRoutes, webpack).
how to solve it !
next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
}
module.exports = nextConfig;
Api Route when i tried to get something , app/api/user/route.js
its code not working showing error.
import dbConnect from "../../../../lib/connect";
export async function GET(req, res) {
dbConnect()
return new Response('Hello, Next.js! I can make twitter clone', {
status: 200,
});
}