How to use environment variables in Node JS | dotenv Node JS

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ก.ค. 2024
  • In this tutorial, I'll walk you through how to use environment variables in Node.js. I'll show step by step how to set up a .env file to load environment variables, and access them in your Node.js code. I'll use 2 methods to access environment variables, one of them is dotenv package and other is making a change in package.json file directly.
    If you are looking to learn web development with JavaScript, React Js and Node JS , Feel free to reach out to me.
    www.fiverr.com/shankeyraheja
    🔗 Related Videos:
    1. How to read Excel File in Node Js | JavaScript
    • How to read Excel File...
    2. Middleware in Node Js Express App
    • How to use Middleware ...
    3. Send Emails in JavaScript & Node Js using Nodemailer
    • How to create sidebar ...
    Reach out to me for Collaboration on the Project:
    shankeyraheja.com/
  • แนวปฏิบัติและการใช้ชีวิต

ความคิดเห็น • 2

  • @AriellaDiskorsiaPrasasti
    @AriellaDiskorsiaPrasasti 10 วันที่ผ่านมา +1

    but what if it's not just one file but 2 files that needs .env? what should i add in the script?

    • @mitter-yourtechmate4376
      @mitter-yourtechmate4376  10 วันที่ผ่านมา

      Hello, you will be able to use env variables in any of your .js files, after making changes to package.json. No additional changes needed to access it in multiple files. Thanks