New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cubos/env

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cubos/env

Strict process.env

  • 2.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm version

@cubos/env

This module allow accessing ENV variables in a easier way than standard process.env.SOMETHING. The rational is that when you are accessing a configuration variable you expect it to exist. Sometimes it isn't possible to define a default value.

const something = process.env.SOMETHING; // string | undefined
// You must check before using this var.
if (!something) {
  throw new Error("You must define 'SOMETHING'");
}
import env from "@cubos/env";

// This will throw if $SOMETHING is not defined.
const something = env.SOMETHING; // string

Note: if you want to allow the var to be optional and set a default value, do:

const something = process.env.SOMETHING ?? "default value"; // string

FAQs

Package last updated on 08 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc