From daa5cfe558b35552f1e73a637a13599b7b3f7fd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Jona=C5=A1?= Date: Mon, 30 May 2022 23:27:28 +0200 Subject: [PATCH] fix(core): ensure pnpm v7 install when peer deps are missing (#10522) --- e2e/utils/index.ts | 2 +- .../workspace/src/generators/workspace/workspace.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/e2e/utils/index.ts b/e2e/utils/index.ts index aa4160391776e..433533bc37fb1 100644 --- a/e2e/utils/index.ts +++ b/e2e/utils/index.ts @@ -298,7 +298,7 @@ export function newProject({ if (isCI && packageManager === 'pnpm') { updateFile( '.npmrc', - 'prefer-frozen-lockfile=false\nstrict-peer-dependencies=false' + 'prefer-frozen-lockfile=false\nstrict-peer-dependencies=false\nauto-install-peers=true' ); } diff --git a/packages/workspace/src/generators/workspace/workspace.ts b/packages/workspace/src/generators/workspace/workspace.ts index ff95f62aebf31..552f1ddd39a03 100644 --- a/packages/workspace/src/generators/workspace/workspace.ts +++ b/packages/workspace/src/generators/workspace/workspace.ts @@ -89,6 +89,14 @@ function createPrettierrc(host: Tree, options: Schema) { ); } +// ensure that pnpm install add all the missing peer deps +function createNpmrc(host: Tree, options: Schema) { + host.write( + join(options.directory, '.npmrc'), + 'strict-peer-dependencies=false\nauto-install-peers=true\n' + ); +} + function formatWorkspaceJson(host: Tree, options: Schema) { const path = join( options.directory, @@ -146,6 +154,9 @@ export async function workspaceGenerator(host: Tree, options: Schema) { if (options.cli === 'angular') { decorateAngularClI(host, options); } + if (options.packageManager === 'pnpm') { + createNpmrc(host, options); + } setPresetProperty(host, options); addNpmScripts(host, options); createAppsAndLibsFolders(host, options);