Skip to content

Commit

Permalink
fix(react): support older npm version (#11646)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo authored Aug 19, 2022
1 parent 41bd2cf commit c4a0d85
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/cra-to-nx/src/lib/cra-to-nx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
removeSync,
readdirSync,
} from 'fs-extra';
import { output } from '@nrwl/devkit';

import { addCRAcracoScriptsToPackageJson } from './add-cra-commands-to-nx';
import { checkForUncommittedChanges } from './check-for-uncommitted-changes';
Expand All @@ -17,7 +18,6 @@ import { readNameFromPackageJson } from './read-name-from-package-json';
import { setupTsConfig } from './tsconfig-setup';
import { writeCracoConfig } from './write-craco-config';
import { cleanUpFiles } from './clean-up-files';
import { output } from '@nrwl/devkit';

let packageManager: string;
function checkPackageManager() {
Expand Down Expand Up @@ -60,9 +60,14 @@ export async function createNxWorkspaceForReact(options: Record<string, any>) {
...packageJson.devDependencies,
};
const isCRA5 = /^[^~]?5/.test(deps['react-scripts']);
const npmVersion = execSync('npm -v').toString();
// Should remove this check 04/2023 once Node 14 & npm 6 reach EOL
const npxYesFlagNeeded = !npmVersion.startsWith('6'); // npm 7 added -y flag to npx

execSync(
`npx -y create-nx-workspace@latest temp-workspace --appName=${reactAppName} --preset=react --style=css --packageManager=${packageManager}`,
`npx ${
npxYesFlagNeeded ? '-y' : ''
} create-nx-workspace@latest temp-workspace --appName=${reactAppName} --preset=react --style=css --packageManager=${packageManager}`,
{ stdio: [0, 1, 2] }
);

Expand Down

0 comments on commit c4a0d85

Please sign in to comment.