5

I am using node.js Nodemailer module and encountered the following error;

[Error: Unsupported configuration, downgrade Nodemailer to v0.7.1 or see the migration guide https://github.com/andris9/Nodemailer#migration-guide]

I looked at my package.json and realize that it is "nodemailer": "^1.8.0", version.

How do I downgrade to v0.7.1 and prevent automatic upgrade later when I run npm update?

guagay_wk
  • 26,337
  • 54
  • 186
  • 295

2 Answers2

20

If you need exactly v0.7.1, use "nodemailer": "0.7.1", delete nodemailer under node_modules and run npm install again.

Another way to do this is to run the command:

npm remove nodemailer
npm install nodemailer@0.7.1 --save
David Xu
  • 5,555
  • 3
  • 28
  • 50
  • Thanks. Upvoted. If I run `npm update`, will nodemailer be automatically upgraded? If yes, how can I prevent that? – guagay_wk Nov 08 '15 at 05:30
  • 2
    No, because `npm update` respects the setting in package.json. If you used a caret or tilde then it may upgrade the package. Caret for major version, tilde for minor. "^0.7.1" would match anything under "1.0.0", "~0.7.1" would match anything from "0.7.0" to "0.7.9" – David Xu Nov 08 '15 at 05:31
  • So, make sure it is `"nodemailer": "0.7.1"` and not `"nodemailer": "^0.7.1"`. Is this correct? – guagay_wk Nov 08 '15 at 05:32
  • Re: "^1.1.1" vs "1.1.1"... [See answer here](https://stackoverflow.com/a/22345808/4378314). – Kalnode Jan 18 '20 at 03:15
-1

use this command to install nodemailer with 0.7 version else it will give error while sending emails

npm install nodemailer@0.7.1 --save

var nodemailer = require("nodemailer");

var smtpTransport = nodemailer.createTransport("SMTP",{
   service: "Gmail",
   auth: {
       user: "EMAIL",
       pass: "PASSWORD"
   }
});

var mail = {
    from: "FROM@gmail.com",
    to: "TO@gmail.com",
    subject: "Send Email Using Node.js",
    text: "Node.js New world for me",
    html: "<b>Node.js New world for me</b>"
}

smtpTransport.sendMail(mail, function(error, response){
    if(error){
        console.log(error);
    }else{
        console.log("Message sent: " + response.message);
    }

    smtpTransport.close();
});
Amit
  • 174
  • 1
  • 7