Thu, 09/16/2021 - 16:17
This error occurs when building an NX node (@nwrl/node) app. This error is related @nrwl/node (^12.9.0) that uses Webpack 4 now, which tries to load .mjs
by default.
Solution
1. Create a custom webpack file for you node project
module.exports = (webpackConfig) => {
webpackConfig.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto",
});
return webpackConfig;
};
Reference this file in the workspace json
In the workspace json
, update the build config of your project. To do this, set the webpackConfig
build option to point to the target Webpack file.
Option path:
projects.<your project name>.build.options.webpackConfig
example
{
...
"webpackConfig": "apps/example-app/webpack.config.js"
...
}
Authored by