AnomalyInnovations / serverless-bundle

Optimized packages for ES6 and TypeScript Node.js Lambda functions without any configuration.
https://serverless-stack.com/chapters/package-lambdas-with-serverless-bundle.html
MIT License
533 stars 157 forks source link

Error: npm ls -prod -json -depth=1 failed with code 1 #275

Open lastdoctor opened 2 years ago

lastdoctor commented 2 years ago

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
bernier commented 2 years ago

Same here, the weird thing is that the same code deployed correctly 2 months ago using Github Actions.

dev-jotape commented 2 years ago

if you are using yarn, configure your serverless.yml like this:

custom:
  bundle:
    packager: yarn
calvin-cdev commented 2 years ago

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:

pradella commented 2 years ago

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. 👍