Skip to content

Commit 7b42332

Browse files
authored
fix(nextjs): add semver to required packages in update-package-json (#35384)
## Current Behavior When using @nx/next:build with Yarn PnP, the generated .nx-helpers/with-nx.js requires semver at runtime, but semver is not included in the generated package.json. This causes the application to fail when starting in a deployed environment with the error: "Required package: semver, Required by: /app/.nx-helpers/with-nx.js" ## Expected Behavior The generated package.json should include semver as a dependency so that .nx-helpers/with-nx.js can resolve it at runtime in all package manager environments, including Yarn PnP. ## Related Issue(s) Fixes #34095
1 parent 7fae6ba commit 7b42332

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

packages/next/src/executors/build/lib/update-package-json.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ export function updatePackageJson(
1717
// These are always required for a production Next.js app to run.
1818
// sharp is for next/image https://nextjs.org/docs/messages/sharp-missing-in-production
1919
// critters is required for experimental optimizing CSS
20+
// semver is required by .nx-helpers/with-nx.js at runtime
2021
const requiredPackages = [
2122
'react',
2223
'react-dom',
2324
'next',
2425
'typescript',
2526
'sharp',
2627
'critters',
28+
'semver',
2729
];
2830
for (const pkg of requiredPackages) {
2931
const externalNode = context.projectGraph.externalNodes[`npm:${pkg}`];

0 commit comments

Comments
 (0)