Prerequisites
Before you begin, ensure you have:- Node.js 16.0.0 or higher installed
- A project with at least one
.envfile - npm, yarn, pnpm, or bun package manager
env-twin works with any Node.js project that uses
.env files for environment configuration.Installation and first sync
Run your first sync
Navigate to your project directory and run the sync command:env-twin will automatically:
- Detect all
.env*files in your current directory - Analyze differences between files
- Prompt you to resolve missing keys
- Create a backup before making changes
Example output
Example output
Verify the results
Check your environment files to see the synchronized keys:
env-twin preserves all comments, formatting, and existing values. It only adds missing keys.
What happened?
When you rannpx env-twin sync, the tool:
- Discovered files - Scanned your directory for all
.env*files - Created a backup - Saved a timestamped backup to
.env-twin/directory - Analyzed differences - Compared environment variable keys across all files
- Synchronized keys - Added missing keys to ensure all files have matching variables
- Preserved values - Kept existing values intact, only adding new keys
Next steps
Explore commands
Learn about all available env-twin commands
Backup management
Understand how to manage and restore backups
Best practices
Follow recommended workflows for your team
CI/CD integration
Automate env-twin in your deployment pipeline
Common operations
Create .env.example from .env
If you only need to generate a.env.example file from your .env:
.env to .env.example with sanitized placeholder values.
Restore from backup
If you need to undo changes:Clean old backups
To save disk space, clean up old backups:Troubleshooting
Command not found error
Command not found error
If you see a “command not found” error, make sure you’ve installed env-twin:Then use
npx to run it:No .env* files found
No .env* files found
env-twin looks for environment files in your current directory. Make sure you’re in the right project folder:
Permission denied error
Permission denied error
If you encounter permission errors, check that you have write access to the directory:See the troubleshooting guide for more help.
Get help
Need more assistance?- View detailed command documentation
- Check the troubleshooting guide
- Open an issue on GitHub