diff --git a/packages/monorepo/src/projects/typescript/monorepo-ts.ts b/packages/monorepo/src/projects/typescript/monorepo-ts.ts index 3aac34f73..686c892d8 100644 --- a/packages/monorepo/src/projects/typescript/monorepo-ts.ts +++ b/packages/monorepo/src/projects/typescript/monorepo-ts.ts @@ -171,6 +171,9 @@ export class MonorepoTsProject }, include: ["**/*.ts", ".projenrc.ts"], }, + peerDeps: [...(options.peerDeps || []), "nx@^16"], + devDeps: [...(options.devDeps || []), "nx@^16", "@aws/pdk@^0"], + deps: [...(options.deps || []), "aws-cdk-lib", "constructs", "cdk-nag"], }); this.nxConfigurator = new NxConfigurator(this, { @@ -201,6 +204,12 @@ export class MonorepoTsProject ); break; } + case NodePackageManager.NPM: { + // Allow older versions of peer deps to resolv compatibility issues + this.tasks.tryFind("install")?.reset("npm install --legacy-peer-deps"); + this.tasks.tryFind("install:ci")?.reset("npm ci --legacy-peer-deps"); + break; + } } this.workspaceConfig = options.workspaceConfig; @@ -272,10 +281,6 @@ export class MonorepoTsProject }); } - // Add dependency on nx 16 - this.addPeerDeps("nx@^16"); - this.addDevDeps("nx@^16", "@aws/pdk@^0"); - this.addDeps("aws-cdk-lib", "constructs", "cdk-nag"); // Needed as this can be bundled in @aws/pdk this.package.addPackageResolutions( "@types/babel__traverse@7.18.2", "wrap-ansi@^7.0.0", diff --git a/packages/pdk/_scripts/exec-command.js b/packages/pdk/_scripts/exec-command.js index 96796b620..653ce4bf7 100755 --- a/packages/pdk/_scripts/exec-command.js +++ b/packages/pdk/_scripts/exec-command.js @@ -27,8 +27,8 @@ const engines = JSON.parse( ).engines; if (engines) { - const pkgMgr = engines.pnpm ? "pnpm" : engines.yarn ? "yarn" : "npm"; - execa.commandSync(`${pkgMgr}${isSynth ? " projen" : ""} ${process.argv.join(" ")}`, { stdio: "inherit" }); + const pkgMgrCmd = engines.pnpm ? "pnpm" : engines.yarn ? "yarn" : "npm run"; + execa.commandSync(`${pkgMgrCmd}${isSynth ? " default" : ""} ${process.argv.join(" ")}`, { stdio: "inherit" }); } else { execa.commandSync(`npx projen ${process.argv.join(" ")}`, { stdio: "inherit"}); }