Sendgrid-nodejs: خطأ في بناء الجملة في نموذج رمز sendgrid node.js ، أثناء وقت التشغيل.

تم إنشاؤها على ٢٩ أغسطس ٢٠١٧  ·  4تعليقات  ·  مصدر: sendgrid/sendgrid-nodejs

ملخص القضية

يظهر لي خطأ في بناء الجملة في mail.js عندما نسخت نموذج رمز sendgrid وحاولت تشغيله على الخادم الخاص بي

خطوات التكاثر

  1. npm install @ sendgrid / mail
  2. تم تصدير متغير البيئة SENDGRID_API_KEY في بيئة bash الخاصة بي
  3. نسخ رمز العينة
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
  to: '[email protected]',
  from: '[email protected]',
  subject: 'Sending with SendGrid is Fun',
  text: 'and easy to do anywhere, even with Node.js',
  html: '<strong>and easy to do anywhere, even with Node.js</strong>',
};
sgMail.send(msg);

اخر خطوة:
قم بتشغيل الكود

# node sendgrid.js
/root/scripts/node_modules/@sendgrid/mail/src/mail.js:6
const {
      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/root/scripts/sendgrid.js:1:78)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

تفاصيل تقنية:

# npm list |grep sendgrid
├─┬ @sendgrid/[email protected]
│ ├─┬ @sendgrid/[email protected]
│ │ ├── @sendgrid/[email protected] deduped
│ └─┬ @sendgrid/[email protected]
├─┬ [email protected]
│ └── [email protected]
npm ERR! extraneous: [email protected] /root/scripts/node_modules/jsprim/node_modules/assert-plus
npm ERR! extraneous: [email protected] /root/scripts/node_modules/verror/node_modules/assert-plus
npm ERR! extraneous: [email protected] /root/scripts/node_modules/dashdash/node_modules/assert-plus
npm ERR! extraneous: [email protected] /root/scripts/node_modules/getpass/node_modules/assert-plus
npm ERR! extraneous: [email protected] /root/scripts/node_modules/sshpk/node_modules/assert-plus
# npm -v 
5.3.0
# node -v
v4.8.4
# echo $SENDGRID_API_KEY
SG.jyr8dVjFTBO4MayuTAS_zA.7a9Qg_XXXXXX
help wanted question

التعليق الأكثر فائدة

مرحبا @ kiranshashiny ،

أعتقد أن هذا لا يعمل من أجلك لأن الإصدار 6 من SDK لا يدعم Node v4.

هل يمكنك الوصول إلى جهاز يستخدم Node v6 أو أعلى؟

مع أطيب التحيات،

إلمر

ال 4 كومينتر

مرحبا @ kiranshashiny ،

أعتقد أن هذا لا يعمل من أجلك لأن الإصدار 6 من SDK لا يدعم Node v4.

هل يمكنك الوصول إلى جهاز يستخدم Node v6 أو أعلى؟

مع أطيب التحيات،

إلمر

هذا صحيح ، الخطأ يحدث في بيان التدمير غير المدعوم في العقدة 4.

قمت بالترقية إلى العقدة 8.x وهي تعمل.

تم إغلاق المشكلة حيث كان الإصلاح هو الترقية.

هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات

القضايا ذات الصلة

egges picture egges  ·  3تعليقات

danielflippance picture danielflippance  ·  4تعليقات

murphman300 picture murphman300  ·  4تعليقات

amlcodes picture amlcodes  ·  4تعليقات

prasoonjalan picture prasoonjalan  ·  3تعليقات