无法在Azure上安装sendgrid

时间:2018-07-05 11:56:19

标签: azure email install sendgrid

我遵循此指南在我的azure Web服务上安装sendgrid: https://docs.microsoft.com/en-us/azure/store-sendgrid-nodejs-how-to-send-email

问题与npm install sendgrid命令有关。

当我在控制台上运行它时,出现以下错误,并且未安装sendgrid。

npm WARN package.json azure-mobile-apps-quickstarts.backend.node.try-mobile-apps@0.0.1 No README.md file found!
npm http GET https://registry.npmjs.org/sendgrid
npm http GET https://registry.npmjs.org/sendgrid
npm http GET https://registry.npmjs.org/sendgrid
npm ERR! Error: SSL Error: CERT_UNTRUSTED
npm ERR!     at ClientRequest.<anonymous> (D:\Program Files (x86)\nodejs\node_modules\npm\node_modules\request\main.js:440:26)
npm ERR!     at ClientRequest.g (events.js:156:14)
npm ERR!     at ClientRequest.emit (events.js:67:17)
npm ERR!     at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1256:7)
npm ERR!     at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:91:29)
npm ERR!     at CleartextStream.socketOnData [as ondata] (http.js:1288:20)
npm ERR!     at CleartextStream._push (tls.js:375:27)
npm ERR!     at SecurePair.cycle (tls.js:734:20)
npm ERR!     at EncryptedStream.write (tls.js:130:13)
npm ERR!     at Socket.ondata (stream.js:38:26)
npm ERR!  [Error: SSL Error: CERT_UNTRUSTED]
npm ERR! You may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "D:\\Program Files (x86)\\nodejs\\\\node.exe" "D:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "sendgrid"
npm ERR! cwd D:\home\site\wwwroot
npm ERR! node -v v0.6.20
npm ERR! npm -v 1.1.37
npm ERR! message SSL Error: CERT_UNTRUSTED

我还尝试将软件包安装在azure上的脚本编辑门户中,结果如下。

\> npm install sendgrid
npm WARN package.json azure-mobile-apps-quickstarts.backend.node.try-mobile-apps@0.0.1 No README data
npm WARN deprecated sendgrid@5.2.3: Please see v6.X+ at https://www.npmjs.com/org/sendgrid
npm WARN deprecated mailparser@0.6.2: This project is unmaintained
npm WARN deprecated mimelib@0.3.1: This project is unmaintained
sendgrid@5.2.3 node_modules\sendgrid
├── lodash.chunk@4.2.0
├── sendgrid-rest@2.4.0
├── bottleneck@1.16.0
├── async.queue@0.5.2 (async.util.queue@0.5.2)
├── async.ensureasync@0.5.2 (async.util.ensureasync@0.5.2)
└── mailparser@0.6.2 (uue@3.1.2, encoding@0.1.12, mimelib@0.3.1)

我也收到此错误:typeerror sendgrid.email is not a function 运行此代码时:

var email = new sendgrid.Email({
    to: 'john@contoso.com',
    from: 'anna@contoso.com',
    subject: 'test mail',
    text: 'This is a sample email message.'
});

1 个答案:

答案 0 :(得分:1)

看起来已弃用您正在使用的sendgrid软件包。请尝试卸载此文件,然后在下面安装一个-

npm i @sendgrid/mail