Closed Diboby closed 1 week ago
This seems a serverless
's intentional behavior: https://github.com/serverless/serverless/blob/main/lib%2Fplugins%2Fesbuild%2Findex.js#L873-L881.
Thank you so much, @hyrious! 👍
The issue was related to npm authentication. From your comment, I understood that Serverless runs npm install
in the background. So, when there is a private dependency, npm requires authentication against the private registry.
In my case, npm authentication was missing from within a Docker container, and unfortunately, I didn’t receive any error logs.
After fixing the authentication process, everything worked fine.
I'm really grateful for your help, @hyrious! 💯
Description
The problem
On my machine (macOs 15), when packaging serverless using esbuild with the option
packages='external'
, anode_modules
folder is added automacally to the build folder. With the same configuration, but run the command from any nodejs docker image (alpine
,bullseye
orbookworm
) does not produce the same output, i-e thenode_modules
folder is not added.Config
My esbuild config file looks like
esbuild.config.mjs
```ts export default (serverless) => { return { entryPoints: ['src/index.ts'], bundle: true, platform: 'node', minify: true, sourcemap: true, packages: 'external', target: 'node20.9', plugins: [], }; }; ```Possible workarounds
npm i --omit=dev
in the build folder: This approach is not possible withserverless deploy
command without providing a package location optionOther informations: