← Back to Node.js Course | Chapter 10: Deployment & Best Practices | Lesson 2 of 7

process.env का उपयोग

process.env वह object है जो running process की हर environment variable hold करता है।

In this page:

  1. process.env
Syntax
javascript
process.env.KEY
process.env.NODE_ENV

process.env

हर value एक string है, और missing वाली undefined हैं। NODE_ENV एक convention है जो कई libraries में production behaviour toggle करता है। process.env को assign करना value को एक string में convert कर देता है।

Note: NODE_ENV=production set करना Express जैसे frameworks तेज़ करता है।

उदाहरण: process.env

javascript
process.env.RETRIES = 3;
console.log(typeof process.env.RETRIES, process.env.RETRIES);
console.log(process.env.NOT_SET);
console.log(process.env.NOT_SET ?? "default value");
console.log("PATH is set:", typeof process.env.PATH === "string");

// Output:
// string 3
// undefined
// default value
// PATH is set: true

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. यह मान लेना कि values numbers या booleans हैं
  2. undefined variables पर depend करना
  3. NODE_ENV inconsistently set करना
चैप्टर सारांश
  • Values strings हैं
  • Missing मतलब undefined
  • NODE_ENV=production behaviour बदलता है
  • Assignments strings बन जाती हैं
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.