8

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.

2 Answers 2

15
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));
Sign up to request clarification or add additional context in comments.

2 Comments

How to run node --trace-warnings node_modules/.bin/nx serve my-api with nx run some-lib:test? Running node --trace-warnings ./node_modules/.bin/nx angular:test gives me following error: node_modules\.bin\nx:2 basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") ^^^^^^^ SyntaxError: missing ) after argument list. I am using Node v20.10.0
It looks like shell code is being passed to node. What is the output of head -1 node_modules/.bin/nx?
1

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"
    }
  }
},

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.