Skip to content

Commit

Permalink
feat: always use nodeLinker: node-modules (#2135)
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonrybczak authored Oct 31, 2023
1 parent 9c52009 commit f433381
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 11 additions & 0 deletions packages/cli/src/commands/init/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import copyFiles from '../../tools/copyFiles';
import replacePathSepForRegex from '../../tools/replacePathSepForRegex';
import fs from 'fs';
import chalk from 'chalk';
import {getYarnVersionIfAvailable} from '../../tools/yarn';
import {executeCommand} from '../../tools/packageManager';

export type TemplateConfig = {
placeholderName: string;
Expand All @@ -27,6 +29,15 @@ export async function installTemplatePackage(
root,
});

// 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

if (packageManager === 'yarn' && getYarnVersionIfAvailable() !== null) {
executeCommand('yarn', ['config', 'set', 'nodeLinker', 'node-modules'], {
root,
silent: true,
});
}

return PackageManager.install([templateName], {
packageManager,
silent: true,
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/tools/packageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ function configurePackageManager(
return executeCommand(pm, args, options);
}

function executeCommand(
export function executeCommand(
command: string,
args: Array<string>,
options: Options,
options: {
root: string;
silent?: boolean;
},
) {
return execa(command, args, {
stdio: options.silent && !logger.isVerbose() ? 'pipe' : 'inherit',
Expand Down

0 comments on commit f433381

Please sign in to comment.