Installation
Installation
Install nviron in your JavaScript or TypeScript project
Prerequisites
Before installing nviron, ensure you have:
- Node.js 16.x or higher
- A package manager: npm, yarn, pnpm, or bun
Install Nviron
Choose your preferred package manager to install nviron:
bash pnpm add nviron bash npm install nviron bash yarn add nviron bash bun add nviron Note: Nviron re-exports Zod, so you don't need to install Zod separately unless you need it for other purposes in your application.
TypeScript Setup
Nviron works seamlessly with TypeScript. If you're using TypeScript, no additional configuration is needed—types are included automatically.
tsconfig.json
Ensure your tsconfig.json has the following settings for optimal compatibility:
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
}
}Verify Installation
Create a simple test file to verify nviron is working correctly:
import { defineEnv, z } from "nviron";
const env = defineEnv({
NODE_ENV: z.enum(["development", "production"]),
});
console.log("✅ Nviron is installed correctly!");
console.log("Environment:", env.NODE_ENV);Run the file:
bash pnpm tsx test.ts bash npx tsx test.ts bash yarn tsx test.ts bash bun test.ts Framework Guides
Check out our framework-specific guides for detailed setup instructions:
What's Next?
Now that you've installed nviron, learn how to use it effectively: