Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
Why I Get "undefined" After Exporting Variables With Bash Script

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!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!