Nx: `ng serve api --prod` throw error

Created on 14 Nov 2018  路  2Comments  路  Source: nrwl/nx

ng serve api --prod

Error:


Configuration 'production' could not be found in project 'api'.
Error: Configuration 'production' could not be found in project 'api'.
    at Architect.getBuilderConfiguration (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular-devkit/architect/src/architect.js:106:23)
    at ServeCommand.runSingleTarget (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular/cli/models/architect-command.js:103:45)
    at ServeCommand.runArchitectTarget (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular/cli/models/architect-command.js:127:35)
    at ServeCommand.run (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular/cli/commands/serve-impl.js:24:21)
    at ServeCommand.validateAndRun (/Developer/Work/SPA/ngx-starter-kit/node_modules/@angular/cli/models/command.js:123:31)
    at process._tickCallback (internal/process/next_tick.js:43:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:763:11)
    at startup (internal/bootstrap/node.js:308:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:878:3)

Source Project:
https://github.com/xmlking/ngx-starter-kit

question / discussion

All 2 comments

You should not use ng serve --prod in actual production!

But for checking locally, you can add a production environment to the project config in angular.json.

"production": {
   "buildTarget": "api:build"
}

If you are running in production you may want to seek out ways to properly run a node process in production such as PM2.

thanks @FrozenPandaz got it working with following config.
yes, my intention is to test app with environment.prod.ts config.

        "serve": {
          "builder": "@nrwl/builders:node-execute",
          "options": {
            "buildTarget": "api:build"
          },
          "configurations": {
            "production": {
              "buildTarget": "api:build:production"
            }
          }
        },
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Koslun picture Koslun  路  3Comments

joelmuskwe picture joelmuskwe  路  3Comments

elliotmendiola picture elliotmendiola  路  3Comments

jasedwards picture jasedwards  路  3Comments

MichaelWarneke picture MichaelWarneke  路  3Comments