I am facing an issue regarding an unexpected character in a node module file.
Below is the content of my next.config.js
file:
/**
* @type {import('next').NextConfig}
*/
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const path = require('path');
const nextConfig = {
/* config options here */
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback.fs = false;
config.resolve.fallback.tls = false;
config.resolve.fallback.net = false;
config.resolve.fallback.dns = false;
}
return config;
}
}
module.exports = {
nextConfig,
optimization: {
minimizer: [new UglifyJsPlugin()],
},
externals: {
saslprep: require("saslprep"),
},
experimental: {
forceSwcTransforms: true,
},
publicRuntimeConfig: {
// for multimedia files
staticFolder: "https://basic.am/static",
},
loaders: [{
test: /.node?$/,
loader: 'babel-loader',
}]
};
Upon running the command npm run build
, I encountered the following error:
warn - Invalid next.config.js options detected:
- The root value contains unexpected properties like nextConfig, optimization, externals, and loaders, which are not in the list of allowed properties.
See more info here: https://nextjs.org/docs/messages/invalid-next-config
warn - You have enabled the experimental feature (forceSwcTransforms) in next.config.js.
warn - Experimental features may lead to unexpected or broken application behavior. Use at your own risk.
info - Linting and type validity checking in progress
info - Generating an optimized production build
Failed to compile.
./node_modules/@mongodb-js/zstd-darwin-x64/zstd.darwin-x64.node
Module parse failed: Unexpected character '`' (1:0)
You may need to configure appropriate loaders to handle this file type. See https://webpack.js.org/concepts#loaders
Import trace for requested module:
...
./node_modules/@napi-rs/snappy-darwin-x64/snappy.darwin-x64.node
Module parse failed: Unexpected character '`' (1:0)
This file requires suitable loaders for processing. Refer to https://webpack.js.org/concepts#loaders for more details.
Import trace for requested module:
...
Build failed due to webpack errors
I attempted to add loaders, but it did not resolve the issue.