serverless-esbuild
serverless-esbuild copied to clipboard
adding esbuild-node-externals fails to compile the project
Describe the bug
I'm looking at integrating esbuild-node-externals
to handle the modules installed.
Unfortunately I'm getting this error with no understanding of what's causing it: error yarn install --frozen-lockfile --non-interactive failed with code 1
. Full logs below
Could this have something to do with the project using turborepo
?
To Reproduce Steps to reproduce the behavior.
- In the root directory run
serverless service-1:deploy --stage staging
- Get this error
error yarn install --frozen-lockfile --non-interactive failed with code 1
Expected behavior
The project should compile using plugin esbuild-node-externals
Screenshots or Logs
serverless › Invoking "deploy" on service "service-1"
service-1 › deploying
service-1 › Running "serverless deploy --stage staging --param QueueUrl=https://sqs.us-east-1.amazonaws.com/13234/staging-queue-job --param pageviewItemSyncQueueArn=arn:aws:sqs:us-east-1:996427624499:staging-queue-job"
service-1 › Running "serverless" from node_modules
service-1 › Deploying service-1 to stage staging (us-east-1, "project-aws" provider)
service-1 › × Stack service-1-staging failed to deploy (1s)
service-1 › Environment: darwin, node 16.16.0, framework 3.23.0 (local) 3.22.0v (global), plugin 6.2.2, SDK 4.3.2
service-1 › Credentials: Serverless Dashboard, "project-aws" provider (https://app.serverless.com/project/apps/project-app/service-1/staging/us-east-1/providers)
service-1 › Docs: docs.serverless.com
service-1 › Support: forum.serverless.com
service-1 › Bugs: github.com/serverless/serverless/issues
service-1 › Error:
service-1 › Error: yarn install --frozen-lockfile --non-interactive failed with code 1
service-1 › at ChildProcess.<anonymous> (/Users/hello/Code/project/project-serverless/node_modules/serverless-esbuild/dist/utils.js:53:24)
service-1 › at ChildProcess.emit (node:events:527:28)
service-1 › at ChildProcess.emit (node:domain:475:12)
service-1 › at maybeClose (node:internal/child_process:1092:16)
service-1 › at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
service-1 › error
service-1 › Error:
service-1 › Error: yarn install --frozen-lockfile --non-interactive failed with code 1
service-1 › at ChildProcess.<anonymous> (/Users/hello/Code/project/project-serverless/node_modules/serverless-esbuild/dist/utils.js:53:24)
service-1 › at ChildProcess.emit (node:events:527:28)
service-1 › at ChildProcess.emit (node:domain:475:12)
service-1 › at maybeClose (node:internal/child_process:1092:16)
service-1 › at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
service-1 ›
Versions (please complete the following information):
- OS: macOS
- Serverless Framework Version: 3.23.0
- Plugin Version: 1.33.0
Additional context
project structure
I'm using serverless compose with turborepo. Here's the structure of the project
- project-repo
- services/
- service1/ <----- where the esbuild configuration is located
- serverless.yml
- esbuild-plugin.js
- package.json
- serverless-compose.yml
esbuild configuration in serverless.yml
esbuild:
exclude:
- pg-native
plugins: esbuild-plugins.js
packager: yarn
target: node14
platform: node
bundle: true
minify: true
sourcemap: true
esbuild-plugin.js
const { nodeExternalsPlugin } = require('esbuild-node-externals');
module.exports = [
nodeExternalsPlugin({
packagePath: ['./package.json'],
}),
];