Skip to content

source-map-support module not found #1131

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

Open
notwaf opened this issue Apr 11, 2025 · 20 comments
Open

source-map-support module not found #1131

notwaf opened this issue Apr 11, 2025 · 20 comments
Labels
bug Something isn't working

Comments

@notwaf
Copy link

notwaf commented Apr 11, 2025

Describe the bug

we use eks-blueprints to deploy out eks infra. trying to run it with aws cdk v2.173.4 gives a module not found error.

Expected Behavior

cdk should run successfully to deploy eks cluster

Current Behavior

error message produced

node:internal/modules/cjs/loader:1405
  const err = new Error(message);
              ^

Error: Cannot find module 'source-map-support/register'
Require stack:
- /private/tmp/node_modules/@aws-quickstart/eks-blueprints/dist/addons/upbound-universal-crossplane/index.js
- /private/tmp/node_modules/@aws-quickstart/eks-blueprints/dist/addons/index.js
- /private/tmp/node_modules/@aws-quickstart/eks-blueprints/dist/index.js
- /private/tmp/test.ts
    at node:internal/modules/cjs/loader:1405:15
    at nextResolveSimple (/opt/homebrew/lib/node_modules/tsx/dist/register-DpmFHar1.cjs:3:942)
    at /opt/homebrew/lib/node_modules/tsx/dist/register-DpmFHar1.cjs:2:2550
    at /opt/homebrew/lib/node_modules/tsx/dist/register-DpmFHar1.cjs:2:1624
    at resolveTsPaths (/opt/homebrew/lib/node_modules/tsx/dist/register-DpmFHar1.cjs:3:760)
    at /opt/homebrew/lib/node_modules/tsx/dist/register-DpmFHar1.cjs:3:1038
    at m._resolveFilename (file:///opt/homebrew/lib/node_modules/tsx/dist/register-Swi4xIvk.mjs:1:789)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1061:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1066:22)
    at Function._load (node:internal/modules/cjs/loader:1215:37) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/private/tmp/node_modules/@aws-quickstart/eks-blueprints/dist/addons/upbound-universal-crossplane/index.js',
    '/private/tmp/node_modules/@aws-quickstart/eks-blueprints/dist/addons/index.js',
    '/private/tmp/node_modules/@aws-quickstart/eks-blueprints/dist/index.js',
    '/private/tmp/test.ts'
  ]
}

Node.js v23.10.0

Reproduction Steps

run the below code

import * as blueprints from '@aws-quickstart/eks-blueprints';

blueprints.EksBlueprint.builder().build();

Possible Solution

No response

Additional Information/Context

running any command in cdk produces this error after migration from v2.133.0 to 2.173.4. not sure if we are doing something wrong, or if there is a bug somewhere

CDK CLI Version

2.173.4 (build 1dadd61)

EKS Blueprints Version

1.16.3

Node.js Version

v22.14.0

Environment details (OS name and version, etc.)

linux, debian 12.9, aarch64

Other information

No response

@notwaf notwaf added the bug Something isn't working label Apr 11, 2025
@shapirov103
Copy link
Collaborator

Do you use sourcemap support anywhere in the project?

I just followed the steps https://aws-quickstart.github.io/cdk-eks-blueprints/getting-started/ with the only modification of running forced install of the lib npm i @aws-quickstart/eks-blueprints --force.

here is my file:

#!/usr/bin/env node
import * as cdk from 'aws-cdk-lib';
import * as blueprints from "@aws-quickstart/eks-blueprints";

const app = new cdk.App();

blueprints.builder().build(app, 'mm');

If you used source map support, please consider installing it with npm install source-map-support.

Happy to provide more insight if you share your codebase.

@notwaf
Copy link
Author

notwaf commented Apr 14, 2025

we do not use source map support anywhere in our code. manual/forced install does indeed fix the issue, but we do not require source-map-support anywhere in our code.

@shapirov103
Copy link
Collaborator

@notwaf if --force flag helped fix it, then great, i assume the initial issue was due to incomplete package installation.
In our package @aws-quickstart/eks-blueprints we do not have explicit dependency on source map, however some transitive libraries have it and it is a common library to enable debugging.

I will update the docs to call out --force option to make sure others don't run into the same.

@notwaf
Copy link
Author

notwaf commented Apr 14, 2025

ah, i meant that manually installing the source-map-support module/package fixes the issue. but it doesn't seem to make much sense since we don't use that package anywhere in our code.

@notwaf
Copy link
Author

notwaf commented Apr 14, 2025

tried to install using npm i @aws-quickstart/eks-blueprints --force but that does not do anything and still produces the module not found error.

@notwaf
Copy link
Author

notwaf commented Apr 15, 2025

also, to clarify, using the sample code that you provided above also gives the same module not found error. this is done in a completely new empty temp directory.

okj% ./test.ts
(node:73893) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:73893) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///private/tmp/ojikasdfokj/test.ts is not specified and it doesn't parse as CommonJS.
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
To eliminate this warning, add "type": "module" to /private/tmp/package.json.
node:internal/modules/cjs/loader:1405
  const err = new Error(message);
              ^

Error: Cannot find module 'source-map-support/register'
Require stack:
- /private/tmp/node_modules/@aws-quickstart/eks-blueprints/dist/addons/upbound-universal-crossplane/index.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1405:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1061:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1066:22)
    at Function._load (node:internal/modules/cjs/loader:1215:37)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1491:12)
    at require (node:internal/modules/helpers:135:16)
    at Object.<anonymous> (/private/tmp/node_modules/@aws-quickstart/eks-blueprints/dist/addons/upbound-universal-crossplane/index.js:11:1)
    at Module._compile (node:internal/modules/cjs/loader:1734:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/private/tmp/node_modules/@aws-quickstart/eks-blueprints/dist/addons/upbound-universal-crossplane/index.js'
  ]
}

Node.js v23.11.0
Mon Apr 14 17:3

@shapirov103
Copy link
Collaborator

I see you are running test.ts command which errors out. Please follow the instructions from the getting started guide here.

The ts file is expected to be under /bin folder and the execution command is cdk list or cdk deploy.

I have not tried it with node v23.11. I would advise to stick with LTS releases like v22.14.0.
So with node 22.14.0 I tested the following code:

import * as cdk from 'aws-cdk-lib';
import * as blueprints from "@aws-quickstart/eks-blueprints";

const app = new cdk.App(); 

blueprints.EksBlueprint.builder().version("auto").build(app, 'mm');

As an example I am attaching my sample project. Unzip it to a new folder and run npm i --force in that folder . Then run cdk list or cdk deploy. The file that contains the blueprint is ./bin/myblueprints.ts.

myblueprints.zip

@notwaf
Copy link
Author

notwaf commented Apr 15, 2025

gotcha, let me test this out. it errors out whether run with ./test.ts or with cdk diff/list/etc

@notwaf
Copy link
Author

notwaf commented Apr 15, 2025

hrm.... following what you described above does in fact work and i can see that source-map-support was installed in the node_modules dir in that test/temp dir. however, if i clean up our repo and completely remove all node_modules dirs and run a npm i --force, source-map-support does not get installed into node_modules.

@notwaf
Copy link
Author

notwaf commented Apr 16, 2025

i should also clarify that we use npx + npm to run this as well as workspaces, which i forgot to mention originally. there might be some weird interaction going on that causes the module to not be installed

we invoke the cdk call by doing npx cdk diff blah, with appropriate env vars

@shapirov103
Copy link
Collaborator

shapirov103 commented Apr 16, 2025

@notwaf you can add source map as an explicit dependency with npm install source-map-support. I have a permanent alias for cdk="npx cdk", it works for me.

When dropping node_modules please also drop package-lock.json:

rm -rf node_modules
rm package-lock.json
npm i --force

@notwaf
Copy link
Author

notwaf commented Apr 16, 2025

ahh let me try that. yeah, adding source-map-support as an explicit dependency does work, but it shouldn't be necessary i think. let me test that again.

@notwaf
Copy link
Author

notwaf commented Apr 16, 2025

nope, no cigar. removed the node_modules dir and package-lock file. then ran npm i --force and it still errors with module not found.

@shapirov103
Copy link
Collaborator

what version of npm? seems like it is more on the npm side than anything else. I tested with 10.9.2

@notwaf
Copy link
Author

notwaf commented Apr 16, 2025

npm --version
11.3.0

@notwaf
Copy link
Author

notwaf commented Apr 16, 2025

it does look like the upbound addon does in fact import source-map-support (

import 'source-map-support/register';
), which is interesting

@shapirov103
Copy link
Collaborator

shapirov103 commented Apr 16, 2025

make sure in your tsconfig you exclude node_modules (see example tsconfig.json that I shared before). if you can supply some simplified codebase that I can use to reproduce, that would enable me to give you a better answer.

That is assuming that you don't use upbound addon. If you do, then please add sourcemap to your package.json

@notwaf
Copy link
Author

notwaf commented Apr 16, 2025

yeah, we don't use the upbound addon. added the excludes to the tsconfig file as well.

i do realize that we differ slightly in the way we invoke cdk. we use tsx to invoke it instead of node. the sample file that you gave above is what i'm testing in the bin dir of our cdk, which still errors.

the below code in our repo produces the module not found error.

#!/usr/bin/env tsx

import * as cdk from 'aws-cdk-lib';
import * as blueprints from "@aws-quickstart/eks-blueprints";

const app = new cdk.App();

blueprints.builder().build(app, 'mm');

also attaching the tsconfig files in case there's something there also:
these are in the root of the repo
tsconfig.base.json
tsconfig.node.json

this is where we invoke cdk from, 2 dirs in from the root of the repo
tsconfig.json

@shapirov103
Copy link
Collaborator

@notwaf given the peculiarity of your setup compared to what we test against, would the workaround of explicit sourcemap declaration work for you in the interim? It seems that tsx approach tries to compile imported modules regardless of the settings.

I will fix the upbound addon now, it will be in the next release which I expect shortly, depending on how fast we can process the auto mode PR that is currently in draft.

@notwaf
Copy link
Author

notwaf commented Apr 16, 2025

yep, we'll include the explicit declaration for now. or wait for the pr to merge in. thanks!

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

No branches or pull requests

2 participants