How to downgrade this node.js module to specific version and prevent automatic upgrade later?

霸气de小男生 提交于 2020-01-01 18:55:14

问题


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?


回答1:


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



回答2:


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();
});


来源:https://stackoverflow.com/questions/33591036/how-to-downgrade-this-node-js-module-to-specific-version-and-prevent-automatic-u

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!