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
In that context, could you try to add package.json under files section?
artifacts: files: - package.json .... discard-paths: no