Search code examples
amazon-web-servicesamazon-s3amazon-ec2aws-code-deploy

Script at specified location: deployment_script/after_install.sh run as user root failed with exit code 1


Trying to deploy my application in AWS codedeploy,

Having the application in S3 as a zip, but facing the following issue while deploying in codedeploy, please suggest some ways to solve this issue.

Script at specified location: deployment_script/after_install.sh run as user root failed with exit code 1

[stderr]npm WARN @firebase/database-compat@0.1.8 requires a peer of @firebase/app-compat@0.x but none is installed. You must install peer dependencies yourself.
[stderr]npm WARN eslint-config-sonarqube@1.1.0 requires a peer of @typescript-eslint/eslint-plugin@>= 4.13.0 but none is installed. You must install peer dependencies yourself.
[stderr]npm WARN eslint-config-sonarqube@1.1.0 requires a peer of @typescript-eslint/parser@>= 4.13.0 but none is installed. You must install peer dependencies yourself.
[stderr]npm WARN eslint-config-sonarqube@1.1.0 requires a peer of eslint-plugin-jest@>= 25.0.0 but none is installed. You must install peer dependencies yourself.
[stderr]npm WARN eslint-config-sonarqube@1.1.0 requires a peer of eslint-plugin-jsx-a11y@>= 6.4.0 but none is installed. You must install peer dependencies yourself.
[stderr]npm WARN eslint-config-sonarqube@1.1.0 requires a peer of eslint-plugin-promise@>= 4.2.0 but none is installed. You must install peer dependencies yourself.
[stderr]npm WARN eslint-config-sonarqube@1.1.0 requires a peer of eslint-plugin-react@>= 7.22.0 but none is installed. You must install peer dependencies yourself.
[stderr]npm WARN eslint-config-sonarqube@1.1.0 requires a peer of eslint-plugin-react-hooks@>= 4.2.0 but none is installed. You must install peer dependencies yourself.
[stderr]
[stderr]npm ERR! code ELIFECYCLE
[stderr]npm ERR! errno 1
[stderr]npm ERR! puppeteer@1.20.0 install: `node install.js`
[stderr]npm ERR! Exit status 1
[stderr]npm ERR!
[stderr]npm ERR! Failed at the puppeteer@1.20.0 install script.
[stderr]npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[stderr]
[stderr]npm ERR! A complete log of this run can be found in:
[stderr]npm ERR! /root/.npm/_logs/2023-06-20T20_02_25_858Z-debug.log

And following is in my appspec.yml file:

version: 0.0
os: linux
files:
  - source: /
    destination: /home/ubuntu/node/build/deployment
hooks:  
  ApplicationStop:
    - location: deployment_script/stop_server.sh
      timeout: 300
      runas: root
      
  BeforeInstall:
    - location: deployment_script/before_install.sh
      timeout: 300
      runas: root

  AfterInstall:
    - location: deployment_script/after_install.sh
      timeout: 300
      runas: root

  ApplicationStart:
    - location: deployment_script/start_server.sh
      timeout: 300
      runas: root

  1. Checked for appropriate the user permission for the Root user which is being used.
  2. Checked for the packages and dependencies.

Solution

  • Step 1: Cleared the log space,

    Step 2: Did npm cache clear and reinstalled the npm packages.

    Faced a git error while installing the package did the following command: git config --global url.https://github.com/.insteadOfgit://github.com then did npm install again

    referred the following link for the git error mentioned above : npm install giving error while accessing GIT url

    Step 3: Restarted the AWS deployment pipeline