μν sendgrid μ½λλ₯Ό 볡μ¬νκ³ λ΄ μλ²μμ μ€ννλ €κ³ νλ©΄ mail.jsμμ ꡬ문 μ€λ₯κ° λ°μν©λλ€.
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
μλ νμΈμ @kiranshashiny λ ,
μ΄ SDKμ v6μ Node v4λ₯Ό μ§μνμ§ μκΈ° λλ¬Έμ μ΄κ²μ΄ μλνμ§ μλλ€κ³ μκ°ν©λλ€.
Node v6 μ΄μμ μ¬μ©νλ μμ€ν μ μ‘μΈμ€ν μ μμ΅λκΉ?
λ§μμ λ΄μ,
μλ¨Έ
μ΄κ²μ μ νν©λλ€. λ Έλ 4μμ μ§μλμ§ μλ ꡬ쑰ν λͺ λ Ήλ¬Έμμ μ€λ₯κ° λ°μνκ³ μμ΅λλ€.
λ Έλ 8.xλ‘ μ κ·Έλ μ΄λνλλ° μλν©λλ€.
μμ μ¬νμΌλ‘ λ¬Έμ λ₯Ό λ«λ κ²μ μ κ·Έλ μ΄λμμ΅λλ€.
κ°μ₯ μ μ©ν λκΈ
μλ νμΈμ @kiranshashiny λ ,
μ΄ SDKμ v6μ Node v4λ₯Ό μ§μνμ§ μκΈ° λλ¬Έμ μ΄κ²μ΄ μλνμ§ μλλ€κ³ μκ°ν©λλ€.
Node v6 μ΄μμ μ¬μ©νλ μμ€ν μ μ‘μΈμ€ν μ μμ΅λκΉ?
λ§μμ λ΄μ,
μλ¨Έ