Reputation: 1045
I am working on a NodeJS
project which pulls in @aws-sdk/crt-loader
as a transitive dependency of @aws-sdk/signature-v4-crt
. I am generating a server.js
bundle using esbuild
. When starting my script via ts-node src/server.ts
, it works as expected.
However, when trying to run the bundled version, e.g. node dist/server.js
, my application fails to start, giving the error AWS CRT binary not present in any of the following locations: /local/home/******/******/src/bin/linux-x64-glibc/aws-crt-nodejs.node
(Note that I'm not sure why this path is the "search path" to begin with as I would expect this search path to be in node_modules
).
My esbuild
npm script looks like this:
esbuild src/server.ts --outdir=dist --bundle --platform=node
My tsconfig.json
, if relevant:
{
"compilerOptions": {
"target": "ES2017",
"lib": [
"es2021"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"incremental": true,
"paths": {
"@/*": [
"./src/*"
]
}
},
"include": [
"**/*.ts"
],
"exclude": [
"node_modules"
]
}
My intuition was that I needed to mark the @aws-sdk/crt-loader
as an external by updating my esbuild
script to:
esbuild src/server.ts --outdir=dist --bundle --platform=node --external:@aws-sdk/crt-loader
However, this did not resolve my issue.
What steps can I take to troubleshoot and or resolve this issue?
Upvotes: 0
Views: 114
Reputation: 21
Alternative: Use esbuild-plugin-copy If you prefer not to manually copy the binary, you can use the esbuild-plugin-copy plugin to automate this process. Install the plugin:
npm install esbuild-plugin-copy --save-dev
Upvotes: 1
Reputation: 1045
Install the npm module that packages the binary locally.
npm install aws-crt
Update build script to mark aws-crt
as an external:
esbuild src/server.ts --outdir=dist --bundle --platform=node --external:aws-crt
References:
Upvotes: 0