I am trying to export global variables using a Bash
script to use their values in my JS express
API.
Here is my code:
.../Backend/index.js:
const express = require('express');
const app = express();
const root_folder = process.env.ROOT_FOLDER;
app.get('/api', (req, res) => {
res.send(root_folder);
});
const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Listening on port ${port}...`));
../Backend/run.sh:
#!/usr/bin/env bash
export ROOT_FOLDER="~/projects/Publishing_Platform"
export PORT=5000
After I run ./run.sh
and the bash script is executed, I run nodemon index.js
but the exports all say undefined
.
What am I doing wrong?
Thanks for the help!