AWS Beanstalk NodeJS Deployment fails

0

I am trying to deploy a nodejs app using AWS Codepipeline to beanstalk. howwever it fails.

below is the log.

2023/02/26 17:44:57.864956 [INFO] checking package.json file 2023/02/26 17:44:57.864962 [INFO] checking app.js file from source 2023/02/26 17:44:57.864969 [INFO] checking server.js file from source 2023/02/26 17:44:57.864996 [ERROR] An error occurred during execution of command [app-deploy] - [check Procfile]. Stop running the command. Error: node.js may have issues starting. Please provide a package.json file or add server.js/app.js file in source bundle

2023/02/26 17:44:57.865011 [INFO] Executing cleanup logic 2023/02/26 17:44:57.865148 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment: You didn't include a 'package.json' file in your source bundle. The deployment didn't install a specific Node.js version.","timestamp":1677433497864,"severity":"INFO"},{"msg":"Instance deployment failed to generate a 'Procfile' for Node.js. Provide one of these files: 'package.json', 'server.js', or 'app.js'. The deployment failed.","timestamp":1677433497864,"severity":"ERROR"},{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1677433497865,"severity":"ERROR"}]}]}

my build specs

# Do not change version. This is the version of aws buildspec, not the version of your buldspec file.
version: 0.2
phases:
  install:
    runtime-versions:
      nodejs: latest
  pre_build:
    commands:
      - echo Installing source NPM dependencies...
      - npm install
  build:
    commands:
      - echo Build started on `date`
      - echo Compiling the dist folder
      - npm run-script build
  post_build:
    commands:
      - echo Build completed on `date`
# Include only the files required for your application to run.
artifacts:
  files:
    - index.js
    - dist/**/*
    - request-map.js
    - credentials.json
    - node_modules/**/*

package.json is in same folder

asked 2 years ago3537 views
2 Answers
0

I am using AWS codepipeline. where can I change the instructions ?

answered 2 years ago
  • In that context, could you try to add package.json under files section?

    artifacts: files: - package.json .... discard-paths: no

0

Hi,

Seems you need to ensure that NodeJs zip is properly done.

Check this out: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/applications-sourcebundle.html

profile picture
EXPERT
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions