env-base64-json
raw JSON → 1.7.0 verified Sat Apr 25 auth: no javascript
env-base64-json (v1.7.0) is a CLI tool and library that outputs all environment variables as a base64-encoded JSON string. It offers a simple npx command-line interface and a programmatic API for Node.js. Unlike generic JSON encoding utilities, it specifically targets environment variable serialization for secure transmission or storage. The package is rarely updated but is stable and lightweight, with no external dependencies.
Common errors
error Cannot find module 'env-base64-json' ↓
cause Package not installed.
fix
Run 'npm install env-base64-json'.
error ERR_REQUIRE_ESM ↓
cause Attempting to require() an ES module (though this package is CJS).
fix
Use require('env-base64-json') correctly.
Warnings
gotcha Package name in npm is 'env-base64-json', not 'super-test-json'. ↓
fix Use 'npm i env-base64-json' or 'npx env-base64-json'.
gotcha The package does not support ES modules (ESM). Using import will fail. ↓
fix Use require() for CommonJS imports.
gotcha No TypeScript type definitions are provided; TypeScript users may need to create .d.ts files. ↓
fix Manually declare module typings.
Install
npm install super-test-json yarn add super-test-json pnpm add super-test-json Imports
- getEnvBase64Json wrong
import { getEnvBase64Json } from 'env-base64-json';correctconst { getEnvBase64Json } = require('env-base64-json');
Quickstart
const { getEnvBase64Json } = require('env-base64-json');
const base64Env = getEnvBase64Json();
console.log(base64Env);
// Decode it back
const decoded = JSON.parse(Buffer.from(base64Env, 'base64').toString());
console.log(decoded);