Skip to content

fix(@angular/cli): use global version of the CLI when running ng new #24234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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