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] Python pdk command "Cannot find module '../lib/cli.js'" #667

Closed
jstrunk opened this issue Dec 7, 2023 · 5 comments
Closed

[BUG] Python pdk command "Cannot find module '../lib/cli.js'" #667

jstrunk opened this issue Dec 7, 2023 · 5 comments
Labels
backlog bug Something isn't working needs-triage

Comments

@jstrunk
Copy link
Contributor

jstrunk commented Dec 7, 2023

Describe the bug

When running pdk on a Python monorepo in CodeBuild, I get the error "Cannot find module '../lib/cli.js'".

I’m using feature branch pipelines It happens in CodeBuild in a new branch that worked fine on my local machine. New branches cloned from main continue to work. There are new projects in the .projenrc.py, and some package versions are different. I confirmed that builds from main work with both pdk 0.22.42 and 0.22.44. In troubleshooting, I determined that the pdk command being run in CodeBuild is the one installed by poetry. On my local machine, it also runs the pdk installed by poetry. There’s no difference in yarn.lock.

Expected Behavior

I expect pdk to run successfully.

Current Behavior

Error message from build logs

[Container] 2023/12/07 03:53:40.135114 Running command pdk
node:internal/modules/cjs/loader:1080
throw err;
^

Error: Cannot find module '../lib/cli.js'
Require stack:

  • /usr/local/bin/npx
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object. (/usr/local/bin/npx:3:13)
    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:81:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ '/usr/local/bin/npx' ]
    }

Node.js v18.16.1
/root/.cache/aws/jsii/package-cache/@aws/pdk/0.22.44/b9ff9bc92ed9b2038305d406e30c6eb93052224ec3575227a439922f1b343ae4/node_modules/execa/index.js:212
throw error;
^

Error: Command failed with exit code 1: npx projen
at makeError (/root/.cache/aws/jsii/package-cache/@aws/pdk/0.22.44/b9ff9bc92ed9b2038305d406e30c6eb93052224ec3575227a439922f1b343ae4/node_modules/execa/lib/error.js:60:11)
at module.exports.sync (/root/.cache/aws/jsii/package-cache/@aws/pdk/0.22.44/b9ff9bc92ed9b2038305d406e30c6eb93052224ec3575227a439922f1b343ae4/node_modules/execa/index.js:194:17)
at module.exports.commandSync (/root/.cache/aws/jsii/package-cache/@aws/pdk/0.22.44/b9ff9bc92ed9b2038305d406e30c6eb93052224ec3575227a439922f1b343ae4/node_modules/execa/index.js:235:15)
at Object. (/root/.cache/aws/jsii/package-cache/@aws/pdk/0.22.44/b9ff9bc92ed9b2038305d406e30c6eb93052224ec3575227a439922f1b343ae4/_scripts/exec-command.js:39: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:81:12)
at node:internal/main/run_main_module:23:47 {
shortMessage: 'Command failed with exit code 1: npx projen',
command: 'npx projen',
escapedCommand: 'npx projen',
exitCode: 1,
signal: undefined,
signalDescription: undefined,
stdout: undefined,
stderr: undefined,
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}

Node.js v18.16.1

[Container] 2023/12/07 03:54:08.806627 Command did not exit successfully pdk exit status 1

Reproduction Steps

buildspec

version: "0.2"
phases:
  install:
    commands:
      - npm install -g aws-cdk @aws/pdk
      - python3 -m venv .venv
      - . ./.venv/bin/activate
      - pip install poetry
      - poetry install --no-root
      - pdk
  build:
    commands:
      - pdk build
      - cd packages/infra
      - cdk synth
      - cdk deploy --require-approval=never
artifacts:
  files:
    - "**/*"

Possible Solution

No response

Additional Information/Context

No response

PDK version used

0.22.44

What languages are you seeing this issue on?

Python

Environment details (OS name and version, etc.)

CodeBuild STANDARD_7_0

@jstrunk jstrunk added bug Something isn't working needs-triage labels Dec 7, 2023
@jstrunk
Copy link
Contributor Author

jstrunk commented Dec 7, 2023

As a workaround, running npx pdk in the buildspec seems to run the globally installed version, and the build succeeds.

@dbryson
Copy link

dbryson commented Dec 22, 2023

When I have had this problem I have removed node_modules and package-lock.json. Then run npx install and the error seems to go away.

Copy link

This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label.

@agdimech
Copy link
Contributor

Hi - is this still an issue as i've tried to reproduce with no luck :(

@agdimech
Copy link
Contributor

This is resolved in 62f9229

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

No branches or pull requests

4 participants