Skip to content

Commit 352b43e

Browse files
committed
fix(@angular/cli): use require for @angular/core check
This should help with linked node_module scenarios.
1 parent 7b8e0fa commit 352b43e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/@angular/cli/upgrade/version.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as path from 'path';
66

77
import {CliConfig} from '../models/config';
88
import {findUp} from '../utilities/find-up';
9+
import {requireProjectModule} from '../utilities/require-project-module';
910

1011
const resolve = require('resolve');
1112

@@ -83,10 +84,15 @@ export class Version {
8384
}
8485

8586
static assertAngularVersionIs2_3_1OrHigher(projectRoot: string) {
86-
const angularCorePath = path.join(projectRoot, 'node_modules/@angular/core');
87-
const pkgJson = existsSync(angularCorePath)
88-
? JSON.parse(readFileSync(path.join(angularCorePath, 'package.json'), 'utf8'))
89-
: null;
87+
let pkgJson;
88+
try {
89+
pkgJson = requireProjectModule(projectRoot, '@angular/core/package.json');
90+
} catch (_) {
91+
console.error(bold(red(stripIndents`
92+
You seem to not be depending on "@angular/core". This is an error.
93+
`)));
94+
process.exit(2);
95+
}
9096

9197
// Just check @angular/core.
9298
if (pkgJson && pkgJson['version']) {

0 commit comments

Comments
 (0)