npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

envx-gen-pro

v1.0.4

Published

Smart environment manager for Angular: generate environment files and auto-update angular.json / .angular-cli.json

Readme

envx-gen-pro

npm version npm downloads License: MIT GitHub stars

Smart environment manager for Angular.
Create environment.*.ts files and automatically update angular.json or .angular-cli.json with safe and predictable defaults.

👉 View on npm: https://www.npmjs.com/package/envx-gen-pro

What it is
envx-gen-pro is an Angular environment file generator CLI. It helps you create and manage environment.ts, environment.prod.ts, and custom files such as environment.uat.ts or environment.sit.ts. It also updates angular.json fileReplacements or the legacy .angular-cli.json environments map. Ideal for multi environment Angular apps, CI pipelines, and enterprise Angular projects that want a repeatable workflow.


Table of contents


Install

# Recommended
npm i -g envx-gen-pro

# One-off without global install
# npx installs the package then runs the binary
npx -p envx-gen-pro envx --help

# pnpm users
pnpm dlx envx-gen-pro envx --help

# yarn classic users
yarn dlx envx-gen-pro envx --help

Requirements: Node 16 or newer. Works with Angular projects that use angular.json. Also supports older .angular-cli.json projects.


Quick start

# 1) Create the default environment.ts under src/environments
envx gen

# 2) Create environment.sit.ts under src/environments/f1 and update angular.json
envx gen sit --folder=f1

# 3) Create environment.prod.ts and wire fileReplacements for the production configuration
envx gen prod

Why envx-gen-pro

  • No more manual JSON edits for fileReplacements
  • Reuse an existing environment as a template
  • Consistent structure across teams and CI
  • Works with modern Angular CLI and legacy .angular-cli.json
  • Safe by default, refuses to overwrite unless you ask for it

Usage

envx [command] [options]

Commands

gen [name]

Create an environment file and update Angular config.

  • name is optional. If omitted, generates environment.ts
  • If provided, generates environment.<name>.ts

Default source when cloning

  • If src/environments/environment.ts exists, new files are cloned from it
  • Else if src/environments/environment.prod.ts exists, clone from that
  • Else a minimal boilerplate is created

Angular config update

  • For angular.json Angular 6 and newer, updates projects.<project>.architect.build.configurations.<name>.fileReplacements
  • For .angular-cli.json Angular 5 and older, updates apps[0].environments map

Options

--folder <relativePath>   Folder under src/environments for the new file
                          Default: "."
                          Example result: src/environments/<folder>/environment[.<name>].ts

--project <name>          Angular project name to update
                          If omitted, tries "defaultProject" from angular.json

--angular-json <path>     Path to angular.json or .angular-cli.json
                          Default: ./angular.json if present, otherwise ./.angular-cli.json

--no-update-angular       Only write the file. Skip changes to Angular config

--clone-from <path|alias> Explicit source file for cloning
                          Examples:
                          --clone-from=src/environments/environment.prod.ts
                          --clone-from=prod
                          --clone-from=default

--force                   Overwrite if the target file already exists
--dry-run                 Show changes without writing
--yes, -y                 Assume yes for prompts
--json                    Machine readable result output
--verbose                 Extra logs
--version                 Print version
--help                    Show help

Examples

Create the default env file in a feature folder:

envx gen --folder=mobile
# -> src/environments/mobile/environment.ts
# -> updates angular.json default build input when applicable

Create a UAT env and wire replacements:

envx gen uat
# -> src/environments/environment.uat.ts
# -> adds configurations.uat.fileReplacements
#    from environment.ts -> environment.uat.ts

Create SIT under a subfolder and copy from prod:

envx gen sit --folder=f1 --clone-from=prod
# -> src/environments/f1/environment.sit.ts
# -> adds configurations.sit.fileReplacements to point at the new file

Monorepo example with a named project and a custom angular.json path:

envx gen qa --project=dashboard-app --angular-json=apps/dashboard/angular.json

Skip Angular updates if you only want the file:

envx gen stage --no-update-angular

What gets written

File path
src/environments[/<folder>]/environment[.<name>].ts

File content
Exports a plain environment object. If cloning, the entire source file content is copied then normalized. If bootstrapping, a minimal template is created like:

export const environment = {
  production: false
};

How angular.json is updated

When you create or reference a custom environment name, envx adds or updates the fileReplacements entry for that configuration.

Before

{
  "projects": {
    "app": {
      "architect": {
        "build": {
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        }
      }
    }
  }
}

After running envx gen sit

{
  "projects": {
    "app": {
      "architect": {
        "build": {
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            },
            "sit": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.sit.ts"
                }
              ]
            }
          }
        }
      }
    }
  }
}

For .angular-cli.json the apps[0].environments map gets a new key and path.


Use cases

  • Generate Angular environment.ts and environment.prod.ts
  • Create custom environments like environment.uat.ts, environment.sit.ts, environment.qa.ts
  • Automate angular.json fileReplacements
  • Support for Angular workspaces and monorepos
  • Useful for CI or CD pipelines that create build specific environment files

Exit codes

  • 0 success
  • 1 fatal error
  • 2 invalid input or conflicts without --force

Troubleshooting

  • Target file already exists and you did not pass --force
    The command refuses to overwrite. Rerun with --force if you are sure.

  • Project could not be resolved
    Use --project <name> or set defaultProject in angular.json.

  • Using a very old Angular project without angular.json
    Pass --angular-json .angular-cli.json. The tool updates the environments section.

  • Windows shebang issues
    npm creates platform shims for the binary, so it works across OS by default.


Compatibility

  • Node 16 or newer
  • Angular CLI 6 and newer for angular.json
  • Angular CLI 1.x or 5.x supported via .angular-cli.json

Uninstall

npm uninstall -g envx-gen-pro

Contributing

Issues and PRs are welcome. Please include a failing case or a before and after snippet that makes it easy to reproduce.


Related searches

angular environment generator, angular.json fileReplacements automation, angular multiple environment files, angular CLI environment management, environment.ts vs environment.prod.ts, angular environments cli, angular config environments, angular create environment file, angular workspace environments


License

MIT © 2025 Krishna Saathvik Katari