У меня есть код на node js который отлично работает, перенес его на React и он перестал работать.
const nodemailer = require('nodemailer');
function send() {
let transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 587,
auth: {
user: 'myemail',
pass: 'pasworld'
},
secure: false,
requireTLS: true,
});
let result = transporter.sendMail({
from: 'epicgeamstdany2008@gmail.com',
to: 'tdany2008@gmail.com',
// subject: 'Message from Node.js',
// text: 'This message was sent from Node.js server.',
// html: '<p>This message was sent from <b>Node.js</b> server.</p>',
attachments: [
{
filename: '../prez/ров.pdf',
},
{
filename: '../prez/ников.pdf',
},
{
filename: '../prez/ит1.pdf',
},
{
filename: '../prez/рит2.pdf',
},
],
});
console.log(result);
}
function App() {
return (
<div className="App">
<button onClick={send()}/>
</div>
);
}
export default App;
Ошибка:
ERROR in ./node_modules/nodemailer/lib/base64/index.js 3:18-45
Module not found: Error: Can't resolve 'stream' in 'C:\FlDany\Project\Верстка\react\Project\email_send\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 }
Как это исправить?