Skip to content

Commit cd6c8d3

Browse files
authored
fix(nextjs): fix build for yarn pnp (#18387)
1 parent fd6bccd commit cd6c8d3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/next/src/executors/build/build.impl.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import 'dotenv/config';
22
import {
3+
detectPackageManager,
34
ExecutorContext,
5+
getPackageManagerVersion,
46
logger,
57
readJsonFile,
8+
workspaceRoot,
69
writeJsonFile,
710
} from '@nx/devkit';
811
import { createLockFile, createPackageJson, getLockFileName } from '@nx/js';
@@ -53,7 +56,14 @@ export default async function buildExecutor(
5356
process.env.NX_NEXT_OUTPUT_PATH ??= outputPath;
5457

5558
const args = createCliOptions({ experimentalAppOnly, profile, debug });
56-
const command = `npx next build ${args.join(' ')}`;
59+
const isYarnBerry =
60+
detectPackageManager() === 'yarn' &&
61+
gte(getPackageManagerVersion('yarn', workspaceRoot), '2.0.0');
62+
const buildCommand = isYarnBerry
63+
? `yarn next build ${projectRoot}`
64+
: 'npx next build';
65+
66+
const command = `${buildCommand} ${args.join(' ')}`;
5767
const execSyncOptions: ExecSyncOptions = {
5868
stdio: 'inherit',
5969
encoding: 'utf-8',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy