Pass variables form current shell environment to the node app



  • Please help me somebody with passing variables to node app. Given: node app on ubuntu package.json contains

    scripts {
        start: node index.js
    }
    

    The app is started with command npm run start

    Problem: the app requires a ton of environment variables the app runs on the server so i am not using .env file variables are exported in the shell so i can verify they are available in the shell before i do npm run start like so echo $MY_VAR works

    Currently in the sell that has all variables exported when i start the app i get from process.env.MY_VAR is undefined

    PS i’d always been using .env file before but now that i want it to run on the server i have no idea what magic is needed to pass variables form current shell environment to the node app.



  • Ok i figured it out. I simply forgot to export the variables that were declared in the current shell.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2