Skip to content

Commit

Permalink
fix(@angular/cli): use global version of the CLI when running ng new
Browse files Browse the repository at this point in the history
In some cases orphan `node_modules` would cause the non global CLI to be used to generate a new workspace.

Closes #14603

(cherry picked from commit 412cb3e)
  • Loading branch information
alan-agius4 authored and dgp1130 committed Nov 16, 2022
1 parent 5cb23f9 commit eda96de
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/angular/cli/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,21 @@ let forceExit = false;
* See: https://github.com/browserslist/browserslist/blob/819c4337456996d19db6ba953014579329e9c6e1/node.js#L324
*/
process.env.BROWSERSLIST_IGNORE_OLD_DATA = '1';
const rawCommandName = process.argv[2];

/**
* Disable CLI version mismatch checks and forces usage of the invoked CLI
* instead of invoking the local installed version.
*
* When running `ng new` always favor the global version. As in some
* cases orphan `node_modules` would cause the non global CLI to be used.
* @see: https://github.com/angular/angular-cli/issues/14603
*/
if (disableVersionCheck) {
if (disableVersionCheck || rawCommandName === 'new') {
return (await import('./cli')).default;
}

let cli;
const rawCommandName = process.argv[2];

try {
// No error implies a projectLocalCli, which will load whatever
Expand Down

0 comments on commit eda96de

Please sign in to comment.