Node JS JSON question

Posted on 2015-01-19
Last Modified: 2015-02-24
Hello I have a node module that sends email

var nodemailer = require("nodemailer");

var app = express();

var smtpTransport = nodemailer.createTransport("SMTP",
    service: "Gmail",
    auth: {
       user: "",
        pass: "passval"


I would like to save the credentials in a separate json file

File:  security.json

  { "user": "",
    "pass": "passval"


var nodemailer = require("nodemailer");
var credentials = require("./security.json");

var app = express();

var smtpTransport = nodemailer.createTransport("SMTP",
    service: "Gmail",
    auth: {
       user: credentials.user,
        pass: credentials.pass

Question by:Charles Baldo
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 43

Accepted Solution

Rob earned 500 total points
ID: 40559078
What's your question and what is it about your code that doesn't work?

Your code works for me.

Author Closing Comment

by:Charles Baldo
ID: 40629147
Changing it to a .js file worked for me

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
AJAX Create / Update Not working MVC 5 64
How can I do this in Angular, instead of jQuery? 2 22
Jquery Calculation 3 42
close window in firefox 3 37
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question