Skip to content

Commit e3317db

Browse files
committed
feat: always use nodeLinker: node-modules
1 parent 28a75d5 commit e3317db

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

packages/cli/src/commands/init/template.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import copyFiles from '../../tools/copyFiles';
66
import replacePathSepForRegex from '../../tools/replacePathSepForRegex';
77
import fs from 'fs';
88
import chalk from 'chalk';
9+
import {getYarnVersionIfAvailable} from '../../tools/yarn';
10+
import {executeCommand} from '../../tools/packageManager';
911

1012
export type TemplateConfig = {
1113
placeholderName: string;
@@ -27,6 +29,15 @@ export async function installTemplatePackage(
2729
root,
2830
});
2931

32+
// React Native doesn't support PnP, so we need to set nodeLinker to node-modules. Read more here: https://github.com/react-native-community/cli/issues/27#issuecomment-1772626767
33+
34+
if (packageManager === 'yarn' && getYarnVersionIfAvailable() !== null) {
35+
executeCommand('yarn', ['config ', 'set', 'nodeLinker', 'node-modules'], {
36+
root,
37+
silent: true,
38+
});
39+
}
40+
3041
return PackageManager.install([templateName], {
3142
packageManager,
3243
silent: true,

packages/cli/src/tools/packageManager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,13 @@ function configurePackageManager(
5151
return executeCommand(pm, args, options);
5252
}
5353

54-
function executeCommand(
54+
export function executeCommand(
5555
command: string,
5656
args: Array<string>,
57-
options: Options,
57+
options: {
58+
root: string;
59+
silent?: boolean;
60+
},
5861
) {
5962
return execa(command, args, {
6063
stdio: options.silent && !logger.isVerbose() ? 'pipe' : 'inherit',

0 commit comments

Comments
 (0)