https://i.sstatic.net/umv1S.png
In my project, I have a TypeScript and JavaScript blend structure. The bin folder contains a file that creates the CDK stack, while the lib folder holds all of my CDK code for creating AWS resources. However, within the lib folder, there are also multiple JS files that utilize React. My issue arises when attempting to execute 'cdk deploy' as it throws the error 'SyntaxError: Cannot use import statement outside a module'. Despite my efforts to add "type": "module" to my tsconfig file, I encountered another error stating `TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for .../bin/aws-cdk-namespace-deployment.ts`. This particular Typescript file resides in the bin folder and should indeed be using imports. Below is my tsconfig:
{
"compilerOptions": {
"outDir": "./dist/",
"baseUrl": ".",
"target": "es2017",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react",
"downlevelIteration": true
},
"include": [
"src/**/*"
]
}
Here is my package.json:
... (package.json content follows)Despite maintaining the application structure as detailed above, along with the provided tsconfig and package.json configurations, executing 'npm run build && cdk deploy' results in the same error: 'SyntaxError: Cannot use import statement outside a module'. Any assistance or suggestions on resolving this issue would be greatly appreciated.