Skip to content

Commit

Permalink
fix(nextjs): fix build for yarn pnp (#18387)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Aug 1, 2023
1 parent fd6bccd commit cd6c8d3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/next/src/executors/build/build.impl.ts
@@ -1,8 +1,11 @@
import 'dotenv/config';
import {
detectPackageManager,
ExecutorContext,
getPackageManagerVersion,
logger,
readJsonFile,
workspaceRoot,
writeJsonFile,
} from '@nx/devkit';
import { createLockFile, createPackageJson, getLockFileName } from '@nx/js';
Expand Down Expand Up @@ -53,7 +56,14 @@ export default async function buildExecutor(
process.env.NX_NEXT_OUTPUT_PATH ??= outputPath;

const args = createCliOptions({ experimentalAppOnly, profile, debug });
const command = `npx next build ${args.join(' ')}`;
const isYarnBerry =
detectPackageManager() === 'yarn' &&
gte(getPackageManagerVersion('yarn', workspaceRoot), '2.0.0');
const buildCommand = isYarnBerry
? `yarn next build ${projectRoot}`
: 'npx next build';

const command = `${buildCommand} ${args.join(' ')}`;
const execSyncOptions: ExecSyncOptions = {
stdio: 'inherit',
encoding: 'utf-8',
Expand Down

1 comment on commit cd6c8d3

@vercel
Copy link

@vercel vercel bot commented on cd6c8d3 Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx.dev
nx-dev-git-master-nrwl.vercel.app

Please sign in to comment.