@@ -9,7 +9,6 @@ import pnpmLinkBins from '@pnpm/link-bins';
99import {
1010 JsonFile ,
1111 Text ,
12- IPackageJson ,
1312 PackageName ,
1413 FileSystem ,
1514 FileConstants ,
@@ -23,7 +22,7 @@ import { BasePackage } from '../base/BasePackage';
2322import { RushConstants } from '../../logic/RushConstants' ;
2423import { IRushLinkJson } from '../../api/RushConfiguration' ;
2524import { RushConfigurationProject } from '../../api/RushConfigurationProject' ;
26- import { PnpmShrinkwrapFile } from './PnpmShrinkwrapFile' ;
25+ import { PnpmShrinkwrapFile , IPnpmShrinkwrapDependencyYaml } from './PnpmShrinkwrapFile' ;
2726import { PnpmProjectDependencyManifest } from './PnpmProjectDependencyManifest' ;
2827
2928// special flag for debugging, will print extra diagnostic information,
@@ -249,11 +248,17 @@ export class PnpmLinkManager extends BaseLinkManager {
249248
250249 const newLocalFolderPath : string = path . join ( localPackage . folderPath , 'node_modules' , dependencyName ) ;
251250
252- // read the version number
253- const packageJsonForDependency : IPackageJson = JsonFile . load (
254- path . join ( dependencyLocalInstallationRealpath , FileConstants . PackageJson )
255- ) ;
256- const version : string | undefined = packageJsonForDependency . version ;
251+ // read the version number from the shrinkwrap entry
252+ const shrinkwrapEntry : IPnpmShrinkwrapDependencyYaml | undefined =
253+ pnpmShrinkwrapFile . getShrinkwrapEntryFromTempProjectDependencyKey ( tempProjectDependencyKey ) ;
254+ if ( ! shrinkwrapEntry ) {
255+ throw new InternalError ( `Cannot find shrinkwrap entry using dependency key for temp project: ${ project . tempProjectName } ` ) ;
256+ }
257+
258+ const version : string | undefined = shrinkwrapEntry . dependencies [ dependencyName ] ;
259+ if ( ! version ) {
260+ throw new InternalError ( `Cannot find shrinkwrap entry dependency "${ dependencyName } " for temp project: ${ project . tempProjectName } ` ) ;
261+ }
257262
258263 const newLocalPackage : BasePackage = BasePackage . createLinkedPackage (
259264 dependencyName ,
0 commit comments