NodeJS environment variables undefined

I believe the nodemon.json file is only for setting nodemon specific configuration. If you look at the nodemon docs for a sample nodemon.json file, the only env variable they mention setting is NODE_ENV.

Have you considered putting these environment variables for your app in a .env file instead? There is a package called dotenv that is helpful for managing env variables in Node.

First, install dotenv using the command npm install dotenv

Then, create a file called .env in the root directory with the following:

MONGO_ATLAS_PW=xxxxx
JWT_KEY=secret_this_should_be_longer

Finally, inside your app.js file after your imports add the following line:

require('dotenv').config()

I believe you're referring to the dotenv package. To configure it, first create a file called .env with your keys and values stored like so:

MONGO_ATLAS_PW=xxxxx
JWT_KEY=secret_this_should_be_longer

Then, in your server.js, add this near the top:

require("dotenv").config();

Then the process.env variable will be an object containing the values in .env.