serverless-bundle
serverless-bundle copied to clipboard
Error: npm ls -prod -json -depth=1 failed with code 1
Hi guys when I deploy my project I have a problem with the deployment
Error ---------------------------------------------------
Error: npm ls -prod -json -depth=1 failed with code 1
at ChildProcess.<anonymous> (/Users/admin/IdeaProjects/anna-app-backend/node_modules/serverless-webpack/lib/utils.js:91:16)
at ChildProcess.emit (events.js:400:28)
at ChildProcess.emit (domain.js:475:12)
at maybeClose (internal/child_process.js:1058:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 14.18.1
Framework Version: 2.66.1 (local)
Plugin Version: 5.5.1
SDK Version: 4.3.0
Components Version: 3.18.1
serverless.yml
service: ${file(./secrets.json):APP_NAME}
frameworkVersion: '2'
# - serverless-plugin-typescript
plugins:
- serverless-bundle
- serverless-offline
- serverless-offline-s3
- serverless-offline-sns
package:
individually: true
provider:
name: aws
runtime: nodejs14.x
architecture: arm64
region: ${self:custom.REGION}
versionFunctions: false
stage: dev
memorySize: 256
timeout: 30
lambdaHashingVersion: 20201221
custom:
APP_NAME: ${file(./secrets.json):APP_NAME}
bundle:
linting: false
sourcemaps: false
caching: false
stats: false
externals:
- '@nestjs/microservices'
- '@nestjs/mapped-types'
- 'apollo-server-fastify'
- 'cache-manager'
- 'class-transformer'
- 'class-validator'
- '@nestjs/microservices/microservices-module'
- '@nestjs/websockets/socket-module'
- 'class-transformer/storage'
- 'fastify-swagger'
forceInclude:
- pg-native
- pg
serverless-offline:
noPrependStageInUrl: true
functions:
main:
handler: src/lambda.handler
events:
- http:
method: ANY
path: /
- http:
method: ANY
path: '{proxy+}'
variablesResolutionMode: 20210326
Same here, the weird thing is that the same code deployed correctly 2 months ago using Github Actions.
if you are using yarn
, configure your serverless.yml
like this:
custom:
bundle:
packager: yarn
i just ran into this issue and found that it was from having updated my npm version from 6.x to 8.x while doing some other bundling testing. i reset it to 6.x and was fine :+1:
The fix for me was to remove the packages that were using "joi" package.
Fortunately, I was not using it in my project, and then deployment was fine. 👍