Nx: NX does not handle multiple configurations: nx run app:build --configuration=production,stage-env

Created on 9 Apr 2020  路  6Comments  路  Source: nrwl/nx

Expected Behavior

When running commands using nx, they should behave the same as ng

This works
ng run app:build --configuration=production,stage-env

this does not
nx run app:build --configuration=production,stage-env

Current Behavior

It seems that nx is stripping my extra stage-env configurations from the --configuration

Failure Information (for bugs)

I think it has to do with that in earlier version of the angular cli, multiple configurations where not supported, they where added here in November 2019
https://github.com/angular/angular-cli/pull/15819

The problem nx has, is that it only supports one config.
https://github.com/nrwl/nx/blob/115a1abd75e3898beb3f91d93f4edc85b4b9a90b/packages/tao/src/commands/run.ts#L46
https://github.com/nrwl/nx/blob/115a1abd75e3898beb3f91d93f4edc85b4b9a90b/packages/tao/src/commands/run.ts#L120-L138

Solution

Change the implementation so that we are not limited to one config.

core feature

Most helpful comment

I've done some more testing and have found that it's --configuration that is causing the problem

if i do

-c production,test-env

it works
but

---configuration production,test-env

does not work.

So it must be something to do with how we are passing along args.

All 6 comments

I've done some more testing and have found that it's --configuration that is causing the problem

if i do

-c production,test-env

it works
but

---configuration production,test-env

does not work.

So it must be something to do with how we are passing along args.

Interesting, thanks for reporting this! :+1:

For me, none of cases works;
$ nx run app:build -c production,stage-env

returns:

> nx run financeiro:build --c=production,ninedev-production 
Schema validation failed with the following errors:
  Data path "" should NOT have additional properties(--).

and

$ nx run app:build --configuration=production,stage-env

strips the extra stage-env configuration from the --configuration

I'm using these modules versions:

>  NX  Report complete - copy this into the issue template

  @nrwl/angular : 9.5.0
  @nrwl/cli : 9.5.0
  @nrwl/cypress : 9.5.0
  @nrwl/eslint-plugin-nx : 9.5.0
  @nrwl/express : Not Found
  @nrwl/jest : 9.5.0
  @nrwl/linter : 9.5.0
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 9.5.0
  @nrwl/web : Not Found
  @nrwl/workspace : 9.5.0
  typescript : 3.8.3

Adding double quotes for me did the trick.
nx build app -c "production,stage-env"
it translated to:
ng run app:build --c=production,stage-env

None of the following works in my case:

nx build --configuration=production,staging
nx build -c=production,staging
nx build -c production,staging
nx build -c "production,staging"

Each one reports the following error:

>  NX   ERROR  Cannot find configuration 'production,staging' for project 'my-project'

However, this command works fine:

ng build -c=production,staging

Here is my environment:

  Node : 13.7.0
  OS   : win32 x64
  npm  : 6.14.8

  nx : Not Found
  @nrwl/angular : 11.0.8
  @nrwl/cli : 11.0.8
  @nrwl/cypress : 11.0.8
  @nrwl/devkit : 11.0.8
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 11.0.8
  @nrwl/linter : 11.0.8
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 11.0.8
  @nrwl/web : Not Found
  @nrwl/workspace : 11.0.8
  typescript : 4.0.5

I would consider this more as a bug than a feature request. When migrating from the Angular CLI and running node ./decorate-angular-cli.js, scripts that used to work for building your projects no longer work. This is certainly a problem when trying to move to Nx and take advantage of caching (the primary use case motivating this client).

Was this page helpful?
0 / 5 - 0 ratings