Skip to content
Closed
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 @@ -49,9 +49,13 @@ let forceExit = false;

try {
// No error implies a projectLocalCli, which will load whatever
// version of ng-cli you have installed in a local package.json
// version of ng-cli you have installed in a local package.json.
const cwdRequire = createRequire(process.cwd() + '/');
const projectLocalCli = cwdRequire.resolve('@angular/cli');
// Instead of resolving `@angular/cli`, we resolve `@angular/cli/lib/cli/index.js`.
// This ensures that Node.js can only resolve the path if the specific folder
// structure exists in `node_modules`, and it will not be resolved if the
// directory structure is outside of `node_modules` (e.g., package self-referencing).
const projectLocalCli = cwdRequire.resolve('@angular/cli/lib/cli/index.js');
Comment thread
alan-agius4 marked this conversation as resolved.
Comment thread
alan-agius4 marked this conversation as resolved.
cli = await import(projectLocalCli);

const globalVersion = new SemVer(VERSION.full);
Expand Down