javascript 如何将此 node.js 模块降级到特定版本并防止以后自动升级?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33591036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to downgrade this node.js module to specific version and prevent automatic upgrade later?
提问by user781486
I am using node.js Nodemailer module and encountered the following error;
我正在使用 node.js Nodemailer 模块并遇到以下错误;
[Error: Unsupported configuration, downgrade Nodemailer to v0.7.1 or see the migration guide https://github.com/andris9/Nodemailer#migration-guide]
[错误:不支持的配置,将Nodemailer降级到v0.7.1或查看迁移指南 https://github.com/andris9/Nodemailer#migration-guide]
I looked at my package.json and realize that it is "nodemailer": "^1.8.0",
version.
我查看了我的 package.json 并意识到它是"nodemailer": "^1.8.0",
版本。
How do I downgrade to v0.7.1 and prevent automatic upgrade later when I run npm update
?
我如何降级到 v0.7.1 并防止以后运行时自动升级npm update
?
回答by David Xu
If you need exactly v0.7.1, use "nodemailer": "0.7.1"
, delete nodemailer
under node_modules
and run npm install
again.
如果您正好需要 v0.7.1,请使用"nodemailer": "0.7.1"
,删除nodemailer
下node_modules
并npm install
再次运行。
Another way to do this is to run the command:
另一种方法是运行以下命令:
npm remove nodemailer
npm install [email protected] --save
回答by Amit
use this command to install nodemailer with 0.7 version else it will give error while sending emails
使用此命令安装 0.7 版本的 nodemailer 否则它会在发送电子邮件时出错
npm install [email protected] --save
var nodemailer = require("nodemailer");
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "EMAIL",
pass: "PASSWORD"
}
});
var mail = {
from: "[email protected]",
to: "[email protected]",
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();
});