diff --git a/packages/nx/src/lock-file/npm.ts b/packages/nx/src/lock-file/npm.ts index 5c052d95afc51..43ac48c6b7e31 100644 --- a/packages/nx/src/lock-file/npm.ts +++ b/packages/nx/src/lock-file/npm.ts @@ -157,10 +157,11 @@ function mapPackageDependency( peer, optional, }; - if (!mappedPackages[packageName][key]) { + const rootVersion = + isRootVersion ?? packagePath.split('/node_modules/').length === 1; + + if (!mappedPackages[packageName][key] || rootVersion) { // const packageDependencies = lockfileVersion === 1 ? requires : dependencies; - const rootVersion = - isRootVersion ?? packagePath.split('/node_modules/').length === 1; if (lockfileVersion === 1) { const { requires, ...rest } = value;