Below is the error
[Container] 2023/11/02 01:38:20.083915 Running command npm run build
> php_call@0.1.0 build
> tsc
node_modules/@elastic/transport/lib/connection/HttpConnection.d.ts(3,8): error TS1192: Module '"/codebuild/output/src4163126657/src/node_modules/hpagent/index"' has no default export.
node_modules/@elastic/transport/lib/connection/HttpConnection.d.ts(4,8): error TS1192: Module '"http"' has no default export.
node_modules/@elastic/transport/lib/connection/HttpConnection.d.ts(5,8): error TS1192: Module '"https"' has no default export.
[Container] 2023/11/02 01:38:33.444330 Command did not exit successfully npm run build exit status 2
[Container] 2023/11/02 01:38:33.447787 Phase complete: BUILD State: FAILED
[Container] 2023/11/02 01:38:33.447803 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm run build. Reason: exit status 2
I have used AWS CDK to set up a pipeline and have used a nodeJSfunction to create a lambda stack. but I am stuck in the build pharse with this error... Could anyone help?
Below is my source code Lambda Stack
const db = new NodejsFunction(this, 'phpcall', {
bundling: {
nodeModules: ['axios', 'crypto', '@elastic/elasticsearch']
}
})
import statement in Lambda code
I have tried
import { Client } from '@elastic/elasticsearch'
and
"import * as elasticClient from '@elastic/elasticsearch' "
but either one of them can work
I fixed above issue by putting the following inside the tsconfig.json file:
{ "compilerOptions": { ... "esModuleInterop": true ... } }