tanner2379
tanner2379

Reputation: 248

How do you run nx serve with node --trace-warnings?

I start my app with

yarn nx serve my-api

There is an error in the build of an unknown origin that is being obfuscated by node. The console output says "Use node --trace-warnings ... to show where the warning was created". How do I run yarn nx serve in conjunction with --trace-warnings? I want to get the stack trace so that I can find my error.

Upvotes: 8

Views: 26461

Answers (2)

Dave
Dave

Reputation: 708

node --trace-warnings node_modules/.bin/nx serve my-api

Alternatively, you could include this code within your application:

process.on('warning', e => console.warn(e.stack));

Upvotes: 15

m4r00p
m4r00p

Reputation: 1519

You can add a runtime argument in the project.json as follow:

"serve": {
  "executor": "@nx/js:node",
  "defaultConfiguration": "development",
  "options": {
    "watch": false,
    "buildTarget": "api-node:build"
  },
  "configurations": {
    "development": {
      "buildTarget": "api-node:build:development",
      "runtimeArgs": [
        "--trace-warnings"
      ]
    },
    "production": {
      "buildTarget": "api-node:build:production"
    }
  }
},

Upvotes: 1

Related Questions