0

Running basic express app, nothing crazy, everything worked on NX 15. After upgrade and standard:

 nx migrate latest
 nx migrate --run-migrations
 rm -rf node_modules
 npm i

getting this error:

> nx run api:serve --port 3000 --inspect


 >  NX   Unable to resolve @nx/node:webpack.

   Cannot find executor 'webpack' in  ...\node_modules\@nx\node\executors.json.

..\node_modules@nx\node\executors.json looks like this:

{
  "executors": {
    "node": {
      "implementation": "./src/executors/node/node.impl",
      "schema": "./src/executors/node/schema.json",
      "description": "Execute a Node application."
    }
  },
  "builders": {
    "node": {
      "implementation": "./src/executors/node/compat",
      "schema": "./src/executors/node/schema.json",
      "description": "Execute a Node application."
    }
  }
}

and project.json looks like this:

{
  "name": "api",
  "$schema": "..\\..\\node_modules\\nx\\schemas\\project-schema.json",
  "sourceRoot": "apps/api/src",
  "projectType": "application",
  "targets": {
    "build": {
      "executor": "@nx/node:webpack",
      "outputs": ["{options.outputPath}"],
      "options": {
        "outputPath": "dist/apps/api",
        "main": "apps/api/src/server.ts",
        "tsConfig": "apps/api/tsconfig.app.json",
        "assets": ["apps/api/src/assets"]
      },
      "configurations": {
        "production": {
          "optimization": true,
          "extractLicenses": true,
          "inspect": false,
          "fileReplacements": [
            {
              "replace": "apps/api/src/environments/environment.ts",
              "with": "apps/api/src/environments/environment.prod.ts"
            }
          ]
        }
      }
    },
    "serve": {
      "executor": "@nx/node:node",
      "options": {
        "buildTarget": "api:build"
      },
      "configurations": {
        "production": {
          "buildTarget": "api:build:production"
        }
      }
    },
    "lint": {
      "executor": "@nx/linter:eslint",
      "outputs": ["{options.outputFile}"],
      "options": {
        "lintFilePatterns": ["apps/api/**/*.ts"]
      }
    },
    "test": {
      "executor": "@nx/jest:jest",
      "outputs": ["{workspaceRoot}/coverage/apps/api"],
      "options": {
        "jestConfig": "apps/api/jest.config.ts",
        "passWithNoTests": true
      }
    }
  },
  "tags": []
}

Both commands nx build and nx serve throw webpack error. Not sure what is the fix here Let me know if you need more details

Update: Solution bellow

I just simply created another node/express app and copied all the files from API app to NEW_API..

# create new
nx g @nx/express:app new-api --frontendProject client

# remove old
nx g @nx/workspace:rm api

# rename
nx g mv --project new-api api

that's it, no issues with running NEW_API...

...sorry if my lack of interest to trying to resolve this disappoints you =)

697
  • 321
  • 4
  • 16
  • 1
    If you can share your the github repo It would really help but if you can't can you also shared your `package.json` – Nico Jun 01 '23 at 22:20
  • Thanks for your interest, I actually found a workaround and an easy fix essentially. Please see the update – 697 Jun 02 '23 at 18:19
  • Running into this same issue as well – Kurt W Jul 12 '23 at 19:18

1 Answers1

0

the executor for serve is now @nx/js:node while the build should be @nx/webpack:webpack

reference: https://github.com/nrwl/nx/issues/15903#issuecomment-1539976285

yonadav bar ilan
  • 550
  • 6
  • 10