Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: NPM Workspace throws
ENOWORKSPACES
error when fetching registry (…
…#68522) ### Why? This issue occurs when a project is NPM Workspace, and has no other package managers but NPM is installed. Next.js runs [npm config get registry](https://github.com/vercel/next.js/blob/e35710f71f8e0f2844add1a97513a65a54a6f2a3/packages/next/src/lib/helpers/get-registry.ts#L13) to fetch the registry. However, running `npm config get registry` at a NPM Workspace is not allowed resulting a `ENOWORKSPACES` error. ``` $ npm config get registry npm error code ENOWORKSPACES npm error This command does not support workspaces. ``` As we didn't consume the error, it threw when the enabled `next telemetry` [triggered getVersionInfo](https://github.com/vercel/next.js/blame/fb2d2dd01a5f73ac62c4809b7b9c1490617f8705/packages/next/src/server/dev/hot-reloader-webpack.ts#L725-L728) calling `getRegistry` which threw as above. ### How? Add `--no-workspaces` flag when the pkgManager is `'npm'`. It is safe for non-workspace projects as it's equivalent to default `--workspaces=false`. Fixes #47121 Fixes NEXT-832 Fixes NDX-150 --------- Co-authored-by: Sebastian Silbermann <[email protected]>
- Loading branch information