hello i am currently trying to build a small project where i want to send e-mails via nodemailer. My problem is that when i try to build the project with npm run build (ng build)
I get a lot of errors because I don't seem to have polyfills configured.
This is just an excerpt, there were about 20 other module errors due to the pollyfills
./node_modules/nodemailer/lib/base64/index.js:3:18-45 - Error: Module not found: Error: Can't resolve 'stream' in 'C:\Users\Justi\Weihnachten_2023_Codes\node_modules\nodemailer\lib\base64'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "stream": false }
so I have added a custom_weback config in my package.json
{
"name": "Weihanchten",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"build": "ng build ",
"start": "ng serve",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"lint": "ng lint"
},
"config": {
"ionic_webpack": "custom.webpack.config.js"
},
in the custom webpackeg config I wrote the following to solve the problem with the pollyfills
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
module.exports = {
plugins: [
new NodePolyfillPlugin(),
],
resolve: {
fallback: {
"stream": require.resolve("stream-browserify"),
"crypto": require.resolve("crypto-browserify"),
"http": require.resolve("stream-http"),
"https": require.resolve("https-browserify"),
"zlib": require.resolve("browserify-zlib"),
"path": require.resolve("path-browserify"),
"os": require.resolve("os-browserify/browser")
}
}
};
Do any of you have an idea what I have done wrong?