Sendgrid-nodejs: λŸ°νƒ€μž„ 쀑 μƒ˜ν”Œ sendgrid node.js μ½”λ“œμ˜ ꡬ문 였λ₯˜μž…λ‹ˆλ‹€.

에 λ§Œλ“  2017λ…„ 08μ›” 29일  Β·  4μ½”λ©˜νŠΈ  Β·  좜처: sendgrid/sendgrid-nodejs

문제 μš”μ•½

μƒ˜ν”Œ sendgrid μ½”λ“œλ₯Ό λ³΅μ‚¬ν•˜κ³  λ‚΄ μ„œλ²„μ—μ„œ μ‹€ν–‰ν•˜λ €κ³  ν•˜λ©΄ mail.jsμ—μ„œ ꡬ문 였λ₯˜κ°€ λ°œμƒν•©λ‹ˆλ‹€.

λ²ˆμ‹ 단계

  1. npm install @sendgrid/mail
  2. λ‚΄ bash ν™˜κ²½μ—μ„œ 내보낸 ν™˜κ²½ λ³€μˆ˜ SENDGRID_API_KEY
  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 λ‹˜ ,

이 SDK의 v6은 Node v4λ₯Ό μ§€μ›ν•˜μ§€ μ•ŠκΈ° λ•Œλ¬Έμ— 이것이 μž‘λ™ν•˜μ§€ μ•ŠλŠ”λ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€.

Node v6 이상을 μ‚¬μš©ν•˜λŠ” μ‹œμŠ€ν…œμ— μ•‘μ„ΈμŠ€ν•  수 μžˆμŠ΅λ‹ˆκΉŒ?

λ§ˆμŒμ„ λ‹΄μ•„,

μ—˜λ¨Έ

λͺ¨λ“  4 λŒ“κΈ€

μ•ˆλ…•ν•˜μ„Έμš” @kiranshashiny λ‹˜ ,

이 SDK의 v6은 Node v4λ₯Ό μ§€μ›ν•˜μ§€ μ•ŠκΈ° λ•Œλ¬Έμ— 이것이 μž‘λ™ν•˜μ§€ μ•ŠλŠ”λ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€.

Node v6 이상을 μ‚¬μš©ν•˜λŠ” μ‹œμŠ€ν…œμ— μ•‘μ„ΈμŠ€ν•  수 μžˆμŠ΅λ‹ˆκΉŒ?

λ§ˆμŒμ„ λ‹΄μ•„,

μ—˜λ¨Έ

이것은 μ •ν™•ν•©λ‹ˆλ‹€. λ…Έλ“œ 4μ—μ„œ μ§€μ›λ˜μ§€ μ•ŠλŠ” ꡬ쑰화 λͺ…λ Ήλ¬Έμ—μ„œ 였λ₯˜κ°€ λ°œμƒν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

λ…Έλ“œ 8.x둜 μ—…κ·Έλ ˆμ΄λ“œν–ˆλŠ”λ° μž‘λ™ν•©λ‹ˆλ‹€.

μˆ˜μ • μ‚¬ν•­μœΌλ‘œ 문제λ₯Ό λ‹«λŠ” 것은 μ—…κ·Έλ ˆμ΄λ“œμ˜€μŠ΅λ‹ˆλ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰