I created a CodePipeline source from S3, and when building the project using CodeBuild, I'm having the below error message. Here is my buildspec file. Someone, help me with this!!
Buildspec file:-
version: 0.2
phases:
pre_build:
commands:
- echo Installing NPM dependencies
- npm install
build:
commands:
- echo Build started on date
- npm run build
post_build:
commands:
# copy the contents of /build to S3
- aws s3 cp --recursive ./build s3://******/
- aws cloudfront create-invalidation --distribution-id E***** --paths /*
artifacts:
files:
- '**/*'
base-directory: build
codebuild log:-
[Container] 2023/10/26 19:03:06.952387 Waiting for agent ping
[Container] 2023/10/26 19:03:07.953498 Waiting for DOWNLOAD_SOURCE
[Container] 2023/10/26 19:03:08.674998 Phase is DOWNLOAD_SOURCE
[Container] 2023/10/26 19:03:08.677942 CODEBUILD_SRC_DIR=/codebuild/output/src962101355/src
[Container] 2023/10/26 19:03:08.678469 YAML location is /codebuild/readonly/buildspec.yml
[Container] 2023/10/26 19:03:08.680577 Setting HTTP client timeout to higher timeout for S3 source
[Container] 2023/10/26 19:03:08.680668 Processing environment variables
[Container] 2023/10/26 19:03:08.891134 No runtime version selected in buildspec.
[Container] 2023/10/26 19:03:08.915425 Moving to directory /codebuild/output/src962101355/src
[Container] 2023/10/26 19:03:08.918265 Unable to initialize cache download: no paths specified to be cached
[Container] 2023/10/26 19:03:08.950681 Registering with agent
[Container] 2023/10/26 19:03:08.950715 Phases found in YAML: 3
[Container] 2023/10/26 19:03:08.950723 PRE_BUILD: 2 commands
[Container] 2023/10/26 19:03:08.950735 BUILD: 2 commands
[Container] 2023/10/26 19:03:08.950739 POST_BUILD: 2 commands
[Container] 2023/10/26 19:03:08.951112 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED
[Container] 2023/10/26 19:03:08.951128 Phase context status code: Message:
[Container] 2023/10/26 19:03:09.016208 Entering phase INSTALL
[Container] 2023/10/26 19:03:09.019088 Phase complete: INSTALL State: SUCCEEDED
[Container] 2023/10/26 19:03:09.019108 Phase context status code: Message:
[Container] 2023/10/26 19:03:09.048350 Entering phase PRE_BUILD
[Container] 2023/10/26 19:03:09.048973 Running command echo Installing NPM dependencies
Installing NPM dependencies
[Container] 2023/10/26 19:03:09.055944 Running command npm install
/codebuild/output/tmp/script.sh: line 4: npm: command not found
[Container] 2023/10/26 19:03:09.062644 Command did not exit successfully npm install exit status 127
[Container] 2023/10/26 19:03:09.067288 Phase complete: PRE_BUILD State: FAILED
[Container] 2023/10/26 19:03:09.067300 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm install. Reason: exit status 127