Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] projen peer dependencies do not match #601

Closed
poziki opened this issue Oct 16, 2023 · 1 comment · Fixed by #602
Closed

[BUG] projen peer dependencies do not match #601

poziki opened this issue Oct 16, 2023 · 1 comment · Fixed by #602
Labels
bug Something isn't working

Comments

@poziki
Copy link

poziki commented Oct 16, 2023

Describe the bug

It appears that projen's latest version is in the ^0.74 range now and I cannot create a new project because of the peer dependency mismatch.

This happens during the npm install phase

Expected Behavior

I expected the project to initially generate without any errors

Current Behavior

poziki@DESKTOP-XXXXX:~/code/pdk-test$ pdk new monorepo-ts --package-manager=npm
/home/poziki/code/pdk-test
└── (empty)


added 1 package in 589ms

9 packages are looking for funding
  run `npm fund` for details
👾 installing external module @aws/pdk...

added 8 packages, and audited 321 packages in 7s

46 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

👾 Installing dependencies...
👾 install | npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @aws/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/projen
npm ERR!   dev projen@"^0.74.17" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer projen@"^0.73" from @aws/[email protected]
npm ERR! node_modules/@aws/pdk
npm ERR!   dev @aws/pdk@"^0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/projen
npm ERR!   peer projen@"^0.73" from @aws/[email protected]
npm ERR!   node_modules/@aws/pdk
npm ERR!     dev @aws/pdk@"^0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /home/poziki/.npm/_logs/2023-10-16T17_57_38_902Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /home/poziki/.npm/_logs/2023-10-16T17_57_38_902Z-debug-0.log
/home/poziki/code/pdk-test/node_modules/projen/lib/task-runtime.js:155
                    throw new Error(`Task "${this.fullname}" failed when executing "${command}" (cwd: ${(0, path_1.resolve)(cwd ?? this.workdir)})`);
                    ^

Error: Task "install" failed when executing "npm install" (cwd: /home/poziki/code/pdk-test)
    at new RunTask (/home/poziki/code/pdk-test/node_modules/projen/lib/task-runtime.js:155:27)
    at TaskRuntime.runTask (/home/poziki/code/pdk-test/node_modules/projen/lib/task-runtime.js:52:9)
    at NodePackage.installDependencies (/home/poziki/code/pdk-test/node_modules/projen/lib/javascript/node-package.js:800:17)
    at NodePackage.postSynthesize (/home/poziki/code/pdk-test/node_modules/projen/lib/javascript/node-package.js:335:18)
    at MonorepoTsProject.synth (/home/poziki/code/pdk-test/node_modules/projen/lib/project.js:332:22)
    at MonorepoTsProject.synth (/home/poziki/code/pdk-test/node_modules/@aws/pdk/monorepo/projects/typescript/monorepo-ts.js:286:15)
    at evalmachine.<anonymous>:9:20
    at Script.runInContext (node:vm:135:12)
    at Object.runInContext (node:vm:283:6)
    at createProject (/home/poziki/.npm/_npx/07946fd0f68b1c52/node_modules/projen/lib/projects.js:97:8)
/home/poziki/.nvm/versions/node/v18.18.2/lib/node_modules/@aws/pdk/node_modules/execa/index.js:212
                throw error;
                ^

Error: Command failed with exit code 1: npx --yes projen@latest new --from @aws/pdk monorepo-ts --package-manager=npm
    at makeError (/home/poziki/.nvm/versions/node/v18.18.2/lib/node_modules/@aws/pdk/node_modules/execa/lib/error.js:60:11)
    at module.exports.sync (/home/poziki/.nvm/versions/node/v18.18.2/lib/node_modules/@aws/pdk/node_modules/execa/index.js:194:17)
    at module.exports.commandSync (/home/poziki/.nvm/versions/node/v18.18.2/lib/node_modules/@aws/pdk/node_modules/execa/index.js:235:15)
    at Object.<anonymous> (/home/poziki/.nvm/versions/node/v18.18.2/lib/node_modules/@aws/pdk/_scripts/exec-command.js:11:9)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
    at node:internal/main/run_main_module:23:47 {
  shortMessage: 'Command failed with exit code 1: npx --yes projen@latest new --from @aws/pdk monorepo-ts --package-manager=npm',
  command: 'npx --yes projen@latest new --from @aws/pdk monorepo-ts --package-manager=npm',
  escapedCommand: 'npx --yes "projen@latest" new --from "@aws/pdk" monorepo-ts "--package-manager=npm"',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

Node.js v18.18.2

Reproduction Steps

command I used:

pdk new monorepo-ts --package-manager=npm

Possible Solution

updating to the latest projen version should do the trick

Additional Information/Context

I tried editing the package.json manually and ran an npm i and things "appeared" to work okay after that. But following this guide: pdk-tutorial, I would have expected the project files and structure to be generated when I put this in the .projenrc.ts

import { MonorepoTsProject } from "@aws/pdk/monorepo";
import {
    DocumentationFormat,
    Language,
    Library,
    ModelLanguage,
    TypeSafeApiProject,
} from "@aws/pdk/type-safe-api";
import { javascript } from "projen";

// rename variable to monorepo for better readability
const monorepo = new MonorepoTsProject({
    name: "my-project",
    packageManager: javascript.NodePackageManager.NPM,
    projenrcTs: true,
});

new TypeSafeApiProject({
    parent: monorepo,
    outdir: "packages/api",
    name: "myapi",
    infrastructure: {
        language: Language.TYPESCRIPT,
    },
    model: {
        language: ModelLanguage.SMITHY,
        options: {
        smithy: {
            serviceName: {
            namespace: "com.aws",
            serviceName: "MyApi",
            },
        },
        },
    },
    runtime: {
        languages: [Language.TYPESCRIPT],
    },
    documentation: {
        formats: [DocumentationFormat.HTML_REDOC],
    },
    library: {
        libraries: [Library.TYPESCRIPT_REACT_QUERY_HOOKS],
    },
    handlers: {
        languages: [Language.TYPESCRIPT],
    },
});

monorepo.synth();

I received the following error when I ran a pdk build:

poziki@XXXXXX:~/code/pdk-test$ pdk build
Unknown command: "build"

Did you mean this?
    npm run build # run the "build" package script

To see a list of supported npm commands, run:
  npm help
/home/poziki/.nvm/versions/node/v18.18.2/lib/node_modules/@aws/pdk/node_modules/execa/index.js:212
                throw error;
                ^

Error: Command failed with exit code 1: npm build
    at makeError (/home/poziki/.nvm/versions/node/v18.18.2/lib/node_modules/@aws/pdk/node_modules/execa/lib/error.js:60:11)
    at module.exports.sync (/home/poziki/.nvm/versions/node/v18.18.2/lib/node_modules/@aws/pdk/node_modules/execa/index.js:194:17)
    at module.exports.commandSync (/home/poziki/.nvm/versions/node/v18.18.2/lib/node_modules/@aws/pdk/node_modules/execa/index.js:235:15)
    at Object.<anonymous> (/home/poziki/.nvm/versions/node/v18.18.2/lib/node_modules/@aws/pdk/_scripts/exec-command.js:31:9)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
    at node:internal/main/run_main_module:23:47 {
  shortMessage: 'Command failed with exit code 1: npm build',
  command: 'npm build',
  escapedCommand: 'npm build',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}

Node.js v18.18.2

so I tried running npm run build instead:

poziki@XXXXXX:~/code/pdk-test$ npm run build

> [email protected] build
> npx projen build

👾 build | npx nx run-many --target=build --output-style=stream --nx-bail

 >  NX   No projects with target build for 0 projects were run


 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target build for 0 projects

I would have expected a 2 in place of a 0 for projects built.

PDK version used

0.22.15

What languages are you seeing this issue on?

Typescript

Environment details (OS name and version, etc.)

wsl -- ubuntu 22.04

@agdimech
Copy link
Contributor

Hi - thanks for opening this.

Fixed as part of: #602

Be sure to install the latest pdk cli (> 0.22.16) and re-try npm install -g @aws/pdk

Note: Ensure you always run the pdk command after modifying the .projenrc.ts file in order to synthesize your changes (this is why you see 0 projects). Once synthesised, you can run pdk build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants