Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: The externalDependency 'webpack-cli' for 'server:build' could not be found #22871

Closed
qstyler opened this issue Apr 18, 2024 · 11 comments
Closed

Comments

@qstyler
Copy link

qstyler commented Apr 18, 2024

Current Behavior

NX started to fail when I try to serve or build my NestJS app. It gives this error if Itry to do so:
Error: The externalDependency 'webpack-cli' for 'server:build' could not be found.

This was happening to my existing project. But I also tried it on a fresh NX install and it behaved the same way.

Expected Behavior

I expect a server to build and/or serve my NestJS app as normal.

GitHub Repo

No response

Steps to Reproduce

You install a fresh and clear nx workspace with NestJS project in it.

npx create-nx-workspace@latest --packageManager pnpm

image

You try to run or build your nest application:

pnpm nx run server:build --verbose --production

You get this error:

NX   Daemon process terminated and closed the connection

Please rerun the command, which will restart the daemon.
If you get this error again, check for any errors in the daemon process logs found in: /Users/kostia/www/ah/nx-test/org/.nx/cache/d/daemon.log

The logfile has this:

[NX Daemon Server] - 2024-04-18T08:34:52.785Z - Started listening on: /var/folders/j7/xhw343n932j1vvwmmvscjb9c0000gn/T/811fdf97adf7a7465abd/d.sock
[NX Daemon Server] - 2024-04-18T08:34:52.788Z - [WATCHER]: Subscribed to changes within: /Users/kostia/www/ah/nx-test/org (native)
[NX Daemon Server] - 2024-04-18T08:34:52.789Z - Established a connection. Number of open connections: 1
[NX Daemon Server] - 2024-04-18T08:34:52.789Z - Established a connection. Number of open connections: 2
[NX Daemon Server] - 2024-04-18T08:34:52.790Z - Closed a connection. Number of open connections: 1
[NX Daemon Server] - 2024-04-18T08:34:52.790Z - [REQUEST]: Client Request for Project Graph Received
[NX Daemon Server] - 2024-04-18T08:34:52.902Z - [REQUEST]: Updated workspace context based on watched changes, recomputing project graph...
[NX Daemon Server] - 2024-04-18T08:34:52.902Z - [REQUEST]: 
[NX Daemon Server] - 2024-04-18T08:34:52.902Z - [REQUEST]: 
[NX Daemon Server] - 2024-04-18T08:34:53.341Z - [REQUEST]: Responding to the client. project-graph
[NX Daemon Server] - 2024-04-18T08:34:53.342Z - Time taken for 'total for creating and serializing project graph' 550.926709ms
[NX Daemon Server] - 2024-04-18T08:34:53.342Z - [WATCHER]: .nx/cache/d/server-process.json was created or restored
[NX Daemon Server] - 2024-04-18T08:34:53.345Z - Done responding to the client project-graph
[NX Daemon Server] - 2024-04-18T08:34:53.345Z - Handled REQUEST_PROJECT_GRAPH. Handling time: 551. Response time: 4.
[NX Daemon Server] - 2024-04-18T08:34:53.357Z - [REQUEST]: Updated workspace context based on watched changes, recomputing project graph...
[NX Daemon Server] - 2024-04-18T08:34:53.357Z - [REQUEST]: .nx/cache/d/server-process.json
[NX Daemon Server] - 2024-04-18T08:34:53.357Z - [REQUEST]: 
/Users/kostia/www/ah/nx-test/org/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]__@[email protected]_ty_3ucfppfglqkeeg5ozfwxzyyns4/node_modules/nx/src/hasher/native-task-hasher-impl.js:32
        const plans = this.planner.getPlansReference(tasks.map((t) => t.id), taskGraph);
                                   ^

Error: The externalDependency 'webpack-cli' for 'server:build' could not be found
    at NativeTaskHasherImpl.hashTasks (/Users/kostia/www/ah/nx-test/org/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]__@[email protected]_ty_3ucfppfglqkeeg5ozfwxzyyns4/node_modules/nx/src/hasher/native-task-hasher-impl.js:32:36)
    at InProcessTaskHasher.hashTasks (/Users/kostia/www/ah/nx-test/org/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]__@[email protected]_ty_3ucfppfglqkeeg5ozfwxzyyns4/node_modules/nx/src/hasher/task-hasher.js:53:50)
    at handleHashTasks (/Users/kostia/www/ah/nx-test/org/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]__@[email protected]_ty_3ucfppfglqkeeg5ozfwxzyyns4/node_modules/nx/src/daemon/server/handle-hash-tasks.js:30:56)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async handleResult (/Users/kostia/www/ah/nx-test/org/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]__@[email protected]_ty_3ucfppfglqkeeg5ozfwxzyyns4/node_modules/nx/src/daemon/server/server.js:110:16)
    at async handleMessage (/Users/kostia/www/ah/nx-test/org/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]__@[email protected]_ty_3ucfppfglqkeeg5ozfwxzyyns4/node_modules/nx/src/daemon/server/server.js:84:9)
    at async /Users/kostia/www/ah/nx-test/org/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]__@[email protected]_ty_3ucfppfglqkeeg5ozfwxzyyns4/node_modules/nx/src/daemon/server/server.js:45:9 {
  code: 'GenericFailure'
}

Node.js v20.11.0

Nx Report

NX   Report complete - copy this into the issue template

Node   : 20.11.0
OS     : darwin-arm64
pnpm   : 9.0.2

nx                 : 18.3.1
@nx/js             : 18.3.1
@nx/jest           : 18.3.1
@nx/linter         : 18.3.1
@nx/eslint         : 18.3.1
@nx/workspace      : 18.3.1
@nx/devkit         : 18.3.1
@nx/eslint-plugin  : 18.3.1
@nx/nest           : 18.3.1
@nx/node           : 18.3.1
@nrwl/tao          : 18.3.1
@nx/web            : 18.3.1
@nx/webpack        : 18.3.1
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/webpack/plugin
@nx/eslint/plugin
@nx/jest/plugin


### Operating System

- [X] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)
@qstyler
Copy link
Author

qstyler commented Apr 18, 2024

Update: it happens when I use pnpm. No problems with npm.

@djadriano
Copy link

One solution for now:
Downgrade your pnpm to version 8, I downgrade to 8.15.2 and works.

@vreddi
Copy link

vreddi commented Apr 19, 2024

I was facing the same thing with "storybook".

The externalDependency 'storybook' for '<package-name>:build-storybook' could not be found

Downgrading pnpm to v8 and regenerating the lock file made it work as a mitigation.

@riceboyler
Copy link
Contributor

Saw the same issues with pnpm@9+ and eslint. Downgrading back to pnpm v8 resolved it.

It would appear NX and pnpm@9 are not friends yet.

@jaqua
Copy link

jaqua commented Apr 19, 2024

i'm using npm and I'm getting the same error.

@kmckee
Copy link

kmckee commented Apr 28, 2024

I was having the same issue using npm. I ran the commands below and it seems to have resolved everything. I'm not sure that all three are required, but I know it resolved my issue after running them all.

nx reset
npm update
npm audit fix

@anteqkois
Copy link

One solution for now: Downgrade your pnpm to version 8, I downgrade to 8.15.2 and works.

This works, don't forget to delete lock file and reinstall packages

@AgentEnder
Copy link
Member

Nx doesn't support pnpm 9 yet. Support for that is currently being tracked in #22850. I'm going to close this as a duplicate.

@OrenSayag
Copy link

Downgrading pnpm didn't work for me.
I installed the package webpack-cli and it was fixed

@MilanKovacic
Copy link
Contributor

@AgentEnder Can you please reopen this?
Issue has nothing to do with pnpm. it also reproduced with npm, when using nx 19.0.1. After downgrade to 18.3.4, issue goes away.

Copy link

github-actions bot commented Jun 8, 2024

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants