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

Cannot find module '@aws-cdk/cx-api' #59

Closed
ethanalef opened this issue Feb 25, 2022 · 10 comments
Closed

Cannot find module '@aws-cdk/cx-api' #59

ethanalef opened this issue Feb 25, 2022 · 10 comments

Comments

@ethanalef
Copy link

ethanalef commented Feb 25, 2022

I tried the cmd: cdklocal --version, it shows the error:

=========================================================

node:internal/modules/cjs/loader:936
throw err;
^

Error: Cannot find module '@aws-cdk/cx-api'
Require stack:

  • /usr/local/lib/node_modules/aws-cdk/lib/api/aws-auth/sdk-provider.js
  • /usr/local/lib/node_modules/aws-cdk-local/bin/cdklocal
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object. (/usr/local/lib/node_modules/aws-cdk/lib/api/aws-auth/sdk-provider.js:6:15)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/usr/local/lib/node_modules/aws-cdk/lib/api/aws-auth/sdk-provider.js',
    '/usr/local/lib/node_modules/aws-cdk-local/bin/cdklocal'
    ]
    }

=========================================================

I tried reinstall via npm but no luck.

@ethanalef
Copy link
Author

ethanalef commented Feb 25, 2022

❯ node -e 'console.log(require("aws-cdk"))'
{
BOOTSTRAP_VERSION_OUTPUT: [Getter],
BOOTSTRAP_VERSION_RESOURCE: [Getter],
BUCKET_DOMAIN_NAME_OUTPUT: [Getter],
BUCKET_NAME_OUTPUT: [Getter],
Bootstrapper: [Getter],
DEFAULT_TOOLKIT_STACK_NAME: [Getter],
Mode: [Getter],
REPOSITORY_NAME_OUTPUT: [Getter],
SDK: [Getter],
SdkProvider: [Getter],
ToolkitInfo: [Getter],
deployStack: [Getter],
destroyStack: [Getter],
PluginHost: [Getter],
cli: [Getter]
}

=========================================================

❯ npm install -g aws-cdk-local aws-cdk

changed 4 packages, and audited 5 packages in 2s

found 0 vulnerabilities

=========================================================

@ethanalef
Copy link
Author

ethanalef commented Feb 25, 2022

I then install the required package:
npm install -g @aws-cdk/cx-api
npm install -g aws-sdk
npm install -g fs-extra
npm install -g chalk

finally I stuck in:

=========================================================

❯ cdklocal --version
/usr/local/lib/node_modules/aws-cdk/lib/logging.js:5
const chalk = require("chalk");
^

Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/local/lib/node_modules/chalk/source/index.js from /usr/local/lib/node_modules/aws-cdk/lib/logging.js not supported.
Instead change the require of index.js in /usr/local/lib/node_modules/aws-cdk/lib/logging.js to a dynamic import() which is available in all CommonJS modules.
at Object. (/usr/local/lib/node_modules/aws-cdk/lib/logging.js:5:15)
at Object. (/usr/local/lib/node_modules/aws-cdk/lib/api/aws-auth/sdk-provider.js:9:19)
at Object. (/usr/local/lib/node_modules/aws-cdk-local/bin/cdklocal:9:18) {
code: 'ERR_REQUIRE_ESM'
}

=========================================================

@adnanaylan
Copy link

adnanaylan commented Feb 25, 2022

Same here. When I try cdklocal with aws-cdk@2.14.0, I get the same error. With aws-cdk@2.13.0, it's fine. It broke our CI/CD pipeline in this morning.

@makies
Copy link

makies commented Feb 28, 2022

me too.

I tryed aws-cdk downgrade. It’s success and no errors.

$ npm install -g aws-cdk@2.13.0
cdk --version
2.13.0 (build b0b744d)

cdklocal --version
2.13.0 (build b0b744d)

@adnanaylan Thanks for your comment.

@vertti
Copy link

vertti commented Feb 28, 2022

Same here.

@mikelane
Copy link

cdk version 2.14.0 is broken in the same way for me. Version 2.13.0 works, though.

@liamor
Copy link

liamor commented Mar 1, 2022

Same with cdk version 2.15.0

@whummer
Copy link
Member

whummer commented Mar 2, 2022

Thanks for reporting @ethanalef @adnanaylan @makies @vertti @mikelane @liamor . We have now released a new version aws-cdk-local@2.14.0 which should provide compatibility with CDK versions 2.14.0 and above. Please keep us posted on how it goes.. Thanks!

@whummer
Copy link
Member

whummer commented Mar 8, 2022

Assuming this is fixed with the latest cdklocal version (2.14.0 and above) - please do let us know if the problem persists.. Thanks!

@whummer whummer closed this as completed Mar 8, 2022
@liamor
Copy link

liamor commented Mar 10, 2022

Can confirm aws-cdk-local@2.14.0 is working with aws-cdk@2.15.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants