Hello everyone.
I have been trying to research and solve this myself for quite some time, but I cannot seem to find a solution for importing and using nodemailer in my app. (Sorry if the following info seems scattered or jumps around - I have just been trying so many different things and I am at a complete loss.)
I’m using Cocos Creator 3.8.1 and have already followed the following steps:
My script already includes:
import nodemailer from 'nodemailer';
Whenever I try to use the imported module the editor throws a missing class error and my script disappears because of a “compile error”. For instance, I will just use the code above and then, in the start section, add:
console.log(nodemailer);
This results in the missing script error in the editor. (if I comment out the code, the script is restored)
I also followed the example in the docs (Cocos Creator 3.8 Manual - External Module Usage Case) and installed protobufjs with no issues, I just cant seem to get nodemailer to work.
Also, when I hover over ‘nodemailer’ at the end of the import, Visual Studio indicates that it is a module and points to the file “index.d.ts”.
But for some reason, when I try something as simple as this:
const nodemailer = require('nodemailer');
console.log(nodemailer);
I receive a message from the console that the nodemailer module was not found.
My package.json in the root project folder has these dependencies listed:
"dependencies": {
"@types/nodemailer": "^6.4.13",
"nodemailer": "^6.9.7",
"protobufjs": "^7.2.5"
}
My tsconfig.json in the root project folder has these compiler options:
"compilerOptions": {
"strict": false,
"allowSyntheticDefaultImports": true
}
I could very easily be overlooking something simple, so I would be happy to answer any questions or give more information!