CDK won't run anything

0

I am trying to generate a CDK project using typescript. I tried following the getting started where you init a project named hello-cdk. Then I just tried making my own project in a different folder. In both cases I get the same result:

C:\work\my-proj>npm run build

> braun-aws@0.1.0 build
> tsc
C:\work\my-proj>cdk synth
C:\work\my-proj\node_modules\ts-node\src\index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
error TS5083: Cannot read file 'C:\work\my-proj\.config\webpack\tsconfig.webpack.json'.

    at createTSError (C:\work\my-proj\node_modules\ts-node\src\index.ts:859:12)
    at reportTSError (C:\work\my-proj\node_modules\ts-node\src\index.ts:863:19)
    at createFromPreloadedConfig (C:\work\my-proj\node_modules\ts-node\src\index.ts:874:36)
    at phase4 (C:\work\my-proj\node_modules\ts-node\src\bin.ts:543:44)
    at bootstrap (C:\work\my-proj\node_modules\ts-node\src\bin.ts:95:10)
    at main (C:\work\my-proj\node_modules\ts-node\src\bin.ts:55:10)
    at Object.<anonymous> (C:\work\my-proj\node_modules\ts-node\src\bin.ts:800:3)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32) {
  diagnosticCodes: [ 5083 ]
}

My versions:

npm: '8.8.0',
node: '16.18.0',
v8: '9.4.146.26-node.22',
uv: '1.43.0',
zlib: '1.2.11',
brotli: '1.0.9',
ares: '1.18.1',
modules: '93',
nghttp2: '1.47.0',
napi: '8',
llhttp: '6.0.10',
openssl: '1.1.1q+quic',
cldr: '41.0',
icu: '71.1',
tz: '2022b',
unicode: '14.0',
ngtcp2: '0.8.1',
nghttp3: '0.7.0'

For devDependencies, there's a few things that could use updating but I didn't change them from what aws-cdk init generated. This is the result of npm-check-updates

 @types/jest       ^27.5.2  →    ^29.2.0
 @types/node      10.17.27  →    18.11.5
 @types/prettier     2.6.0  →      2.7.1
 jest              ^27.5.1  →    ^29.2.2
 ts-jest           ^27.1.4  →    ^29.0.3
 typescript         ~3.9.7  →     ~4.8.4
 constructs        ^10.0.0  →  ^10.1.139

So what seems to be happening here is that somebody was supposed to generate a .config directory with a webpack config in it, and it didn't. What's also interesting is that npm list --all doesn't even mention webpack.

I'm kind of stuck right out of the chute, did I miss a step?

profile picture
wz2b
asked a year ago839 views
2 Answers
2
Accepted Answer

I figured it out. The problem is, I had an environment variable set:

TS_NODE_PROJECT=./.config/webpack/tsconfig.webpack.json

that was residue from a build I was trying to do building another open source module. That being there totally screws up the packaging. I removed that environment variable and it works fine now . I'll leave my question here because I don't see a way to delete it, and maybe it will be useful for somebody. If you see this error, just unset TS_NODE_PROJECT and you'll be fine.

profile picture
wz2b
answered a year ago
0

For me the simpler solution was to set this in my cdk.json "app": "npx tsx bin/s0-api.ts",

Now I use esbuild for test compiles, jest with esbuild to run tests. And now CDK uses tsx to run.
The only think I had to do was set the __dirname const because you no longer get it for free. So I did: const __dirname =process.cwd()

answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions