I'm trying to use the nodemailer
package in my NodeJS app, which I have deployed on Azure. If I execute the app on my localhost everything works fine. If I execute it on Azure it throws the following error:
Thu Jan 25 2018 09:03:31 GMT+0000 (Coordinated Universal Time): Application has thrown an uncaught exception and is terminated:
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> (D:\home\site\wwwroot\node_modules\nodemailer\lib\nodemailer.js:3:16)
at Module._compile (module.js:409:26)
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> (D:\home\site\wwwroot\api\apiAccount.js:5:20)
at Module._compile (module.js:409:26)
This is my package.json:
{
"name": "passport-local-express4",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"test": "make test"
},
"repository": {
"type": "git",
"url": "git@github.com:mjhea0/passport-local-express4.git"
},
"engines": {
"node": "8.9.0"
},
"dependencies": {
"async": "^2.6.0",
"azure-storage": "^2.6.0",
"bcrypt-nodejs": "0.0.3",
"body-parser": "^1.17.2",
"chai": "^1.8.1",
"connect-flash": "^0.1.1",
"cookie-parser": "^1.4.3",
"debug": "^2.6.8",
"express": "^4.15.3",
"express-fileupload": "^0.3.0",
"express-session": "^1.10.1",
"jade": "^1.11.0",
"mocha": "^1.14.0",
"mongoose": "^4.10.6",
"morgan": "^1.8.2",
"node-cache": "^4.1.1",
"nodemailer": "*",
"passport": "^0.2.2",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^1.3.0",
"serve-favicon": "^2.4.3",
"should": "^2.1.1",
"xoauth2": "^1.2.0"
}
}
If I navigate to thenode_modules
directory on Azure, nodemailer
is a folder and all the necessary code is in there. If I run node -v
on the Kudu console the NodeJS version is 8.9.0. The line, which is mentioned in the error message (apiAccount5:20) is:
const nodemailer = require('nodemailer');
If I try to run node app.js
in the Kudu console, there are no errors thrown.
Any ideas?