Skip to content

Commit 6e34d1b

Browse files
committed
fix(@angular/cli): cannot locate bin for temporary package
This fixes an issue where the installation of the temporary Angular CLI failed with `Cannot locate bin for temporary package: @angular/cli.`
1 parent f048db8 commit 6e34d1b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/angular/cli/commands/add-impl.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,13 @@ export class AddCommand extends SchematicCommand<AddCommandSchema> {
205205
if (savePackage === false) {
206206
// Temporary packages are located in a different directory
207207
// Hence we need to resolve them using the temp path
208-
const { status, tempPath } = await installTempPackage(
208+
const { status, tempNodeModules } = await installTempPackage(
209209
packageIdentifier.raw,
210210
packageManager,
211211
options.registry ? [`--registry="${options.registry}"`] : undefined,
212212
);
213213
const resolvedCollectionPath = require.resolve(join(collectionName, 'package.json'), {
214-
paths: [tempPath],
214+
paths: [tempNodeModules],
215215
});
216216

217217
if (status !== 0) {

packages/angular/cli/utilities/install-package.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export async function installTempPackage(
7878
extraArgs?: string[],
7979
): Promise<{
8080
status: 1 | 0;
81-
tempPath: string;
81+
tempNodeModules: string;
8282
}> {
8383
const tempPath = mkdtempSync(join(realpathSync(tmpdir()), 'angular-cli-packages-'));
8484

@@ -121,7 +121,7 @@ export async function installTempPackage(
121121

122122
return {
123123
status: await installPackage(packageName, packageManager, true, installArgs, tempPath),
124-
tempPath,
124+
tempNodeModules,
125125
};
126126
}
127127

@@ -130,15 +130,15 @@ export async function runTempPackageBin(
130130
packageManager: PackageManager = PackageManager.Npm,
131131
args: string[] = [],
132132
): Promise<number> {
133-
const { status: code, tempPath } = await installTempPackage(packageName, packageManager);
133+
const { status: code, tempNodeModules } = await installTempPackage(packageName, packageManager);
134134
if (code !== 0) {
135135
return code;
136136
}
137137

138138
// Remove version/tag etc... from package name
139139
// Ex: @angular/cli@latest -> @angular/cli
140140
const packageNameNoVersion = packageName.substring(0, packageName.lastIndexOf('@'));
141-
const pkgLocation = join(tempPath, packageNameNoVersion);
141+
const pkgLocation = join(tempNodeModules, packageNameNoVersion);
142142
const packageJsonPath = join(pkgLocation, 'package.json');
143143

144144
// Get a binary location for this package

0 commit comments

Comments
 (0)