const Joi = require('joi');Joi.objectId = require('joi-objectid')(Joi);const mongoose = require('mongoose');const users = require('./routes/users');const auth = require('./routes/auth');const express = require('express');const config = require('config');const app = express();mongoose.connect('mongodb://127.0.0.1/vivesbib') .then(() => console.log('Connected to MongoDB...')) .catch(err => console.error('Could not connect to MongoDB...'));console.log('jwtPrivateKey:', config.get('jwtPrivateKey'));if (!config.get('jwtPrivateKey')) { console.error('FATAL ERROR: jwtPrivateKey not defined'); process.exit(1);}app.use(express.json());app.use('/api/users', users);app.use('/api/auth', auth);const port = process.env.PORT || 3000;app.listen(port, () => console.log(`Listening on port ${port}...`));
custom-environment-variables.json
{"jwtPrivateKey": "vivesbib_jwtPrivateKey"}
default.json
{"jwtPrivateKey": ""}
I tried this:$env:jwtPrivateKey = "yourSecretKey"
nodemon index.js
jwtPrivateKey:FATAL ERROR: jwtPrivateKey not defined[nodemon] app crashed - waiting for file changes before starting...