process.env का उपयोग
process.env वह object है जो running process की हर environment variable hold करता है।
In this page:
Syntax
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
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. #}
आम गलतियां
- यह मान लेना कि values numbers या booleans हैं
- undefined variables पर depend करना
- 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: