We would like to deploy this Node website using these aws artefacts (codepipeline, codebuild, etc.)
The website's node version is 15.14.
We have all the code in AWS Codecommit. Everything in the pipeline runs fine until it reach the build phase. I think something is wrong with the yml file, it looks something like this:
version: 0.2
phases:
install:
commands:
- pip install --upgrade pip
- pip install --upgrade awscli
pre_build:
commands:
- echo Pre_build Phass
- npm install
build:
commands:
- echo Build Phase
- sudo npm run build
post_build:
commands:
- echo PostBuild Phase
- aws s3 sync ./dist $S3_BUCKET
The build error log looks like this:
[Container] 2022/05/12 14:15:48 Waiting for agent ping
[Container] 2022/05/12 14:15:49 Waiting for DOWNLOAD_SOURCE
[Container] 2022/05/12 14:15:51 Phase is DOWNLOAD_SOURCE
[Container] 2022/05/12 14:15:51 CODEBUILD_SRC_DIR=/codebuild/output/src603689838/src
[Container] 2022/05/12 14:15:51 YAML location is /codebuild/output/src603689838/src/buildspec.yml
[Container] 2022/05/12 14:15:51 Processing environment variables
[Container] 2022/05/12 14:15:52 No runtime version selected in buildspec.
[Container] 2022/05/12 14:15:54 Moving to directory /codebuild/output/src603689838/src
[Container] 2022/05/12 14:15:54 Configuring ssm agent with target id: codebuild:546baec5-be50-4bf4-80de-e54db29cc695
[Container] 2022/05/12 14:15:54 Successfully updated ssm agent configuration
[Container] 2022/05/12 14:15:54 Registering with agent
[Container] 2022/05/12 14:15:54 Phases found in YAML: 4
[Container] 2022/05/12 14:15:54 INSTALL: 2 commands
[Container] 2022/05/12 14:15:54 PRE_BUILD: 2 commands
[Container] 2022/05/12 14:15:54 BUILD: 2 commands
[Container] 2022/05/12 14:15:54 POST_BUILD: 2 commands
[Container] 2022/05/12 14:15:54 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED
[Container] 2022/05/12 14:15:54 Phase context status code: Message:
[Container] 2022/05/12 14:15:54 Entering phase INSTALL
[Container] 2022/05/12 14:15:54 Running command pip install --upgrade pip
Requirement already satisfied: pip in /root/.pyenv/versions/3.9.5/lib/python3.9/site-packages (21.1.2)
Collecting pip
Downloading pip-22.1-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.1.2
Uninstalling pip-21.1.2:
Successfully uninstalled pip-21.1.2
Successfully installed pip-22.1
WARNING: Running pip as root will break packages and permissions. You should install packages reliably by using venv: https://pip.pypa.io/warnings/venv
[Container] 2022/05/12 14:16:03 Running command pip install --upgrade awscli
Collecting awscli
Downloading awscli-1.23.12-py3-none-any.whl (3.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.8/3.8 MB 30.0 MB/s eta 0:00:00
Collecting botocore==1.25.12
Downloading botocore-1.25.12-py3-none-any.whl (8.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.7/8.7 MB 52.5 MB/s eta 0:00:00
Collecting rsa<4.8,>=3.1.2
Downloading rsa-4.7.2-py3-none-any.whl (34 kB)
Collecting colorama<0.4.5,>=0.2.5
Downloading colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting docutils<0.16,>=0.10
Downloading docutils-0.15.2-py3-none-any.whl (547 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 547.6/547.6 kB 13.4 MB/s eta 0:00:00
Requirement already satisfied: PyYAML<5.5,>=3.10 in /root/.pyenv/versions/3.9.5/lib/python3.9/site-packages (from awscli) (5.4.1)
Requirement already satisfied: s3transfer<0.6.0,>=0.5.0 in /root/.pyenv/versions/3.9.5/lib/python3.9/site-packages (from awscli) (0.5.2)
Requirement already satisfied: urllib3<1.27,>=1.25.4 in /root/.pyenv/versions/3.9.5/lib/python3.9/site-packages (from botocore==1.25.12->awscli) (1.26.8)
Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in /root/.pyenv/versions/3.9.5/lib/python3.9/site-packages (from botocore==1.25.12->awscli) (0.10.0)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /root/.pyenv/versions/3.9.5/lib/python3.9/site-packages (from botocore==1.25.12->awscli) (2.8.2)
Collecting pyasn1>=0.1.3
Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.1/77.1 kB 13.3 MB/s eta 0:00:00
Requirement already satisfied: six>=1.5 in /root/.pyenv/versions/3.9.5/lib/python3.9/site-packages (from python-dateutil<3.0.0,>=2.1->botocore==1.25.12->awscli) (1.16.0)
Installing collected packages: pyasn1, rsa, docutils, colorama, botocore, awscli
Attempting uninstall: botocore
Found existing installation: botocore 1.24.18
Uninstalling botocore-1.24.18:
Successfully uninstalled botocore-1.24.18
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
boto3 1.21.18 requires botocore<1.25.0,>=1.24.18, but you have botocore 1.25.12 which is incompatible.
Successfully installed awscli-1.23.12 botocore-1.25.12 colorama-0.4.4 docutils-0.15.2 pyasn1-0.4.8 rsa-4.7.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
[Container] 2022/05/12 14:16:13 Phase complete: INSTALL State: SUCCEEDED
[Container] 2022/05/12 14:16:13 Phase context status code: Message:
[Container] 2022/05/12 14:16:13 Entering phase PRE_BUILD
[Container] 2022/05/12 14:16:13 Running command echo Pre_build Phass
Pre_build Phass
[Container] 2022/05/12 14:16:13 Running command npm install
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm ERR! code EEXIST
npm ERR! path /codebuild/output/src603689838/src/node_modules/.bin/vue-cli-service
npm ERR! Refusing to delete /codebuild/output/src603689838/src/node_modules/.bin/vue-cli-service: is outside /codebuild/output/src603689838/src/node_modules/@vue/cli-service and not a link
npm ERR! File exists: /codebuild/output/src603689838/src/node_modules/.bin/vue-cli-service
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-05-12T14_16_34_295Z-debug.log
[Container] 2022/05/12 14:16:34 Command did not exit successfully npm install exit status 1
[Container] 2022/05/12 14:16:34 Phase complete: PRE_BUILD State: FAILED
[Container] 2022/05/12 14:16:34 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm install. Reason: exit status 1