Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

235
Visualizações
Angular universal build command to include package.json at root level of dist folder

I am trying to deploy my angular universal app to AWS Elastic beanstalk. I created a code pipeline on AWS where build output is sent to elastic beanstalk. Now elastic beanstalk needs an app.js or server.js or procfile file or package.json to run application but my build folder is like below

--dist/
   --Appname/
       --browser/
       --server/

   -- //here I am expecting package.json file

My Problem: I am trying to build angular universal but I want to include package.json at root level of dist. folder. I tried multiple approaches but the package.json is going to browser folder of build.

Below is what I tried:

Angular.json

"assets": [
  "src/favicon.ico",
  "src/assets",
  { "glob": "package.json", "input": "./", "output": "/" }
],

I also tried solution on this link

Also below is my buildspec file on AWS

version: 0.2

env:
    variables:
        CACHE_CONTROL: "86400"
        S3_BUCKET: "arn:aws:s3:::devemr.growthemr.com"
        BUILD_FOLDER: "dist"
phases:
  install:
    runtime-versions:
        nodejs: 10
    commands:
        - echo Installing source NPM dependencies...
        - npm install
        - npm install -g @angular/cli@next
  build:
    commands:
        - echo Build started 
        - npm run build:ssr
  post_build:
    commands:
        - bash -c "if [ /"$CODEBUILD_BUILD_SUCCEEDING/" == /"0/" ]; then exit 1; fi"
        - aws s3 rm s3://devemr.growthemr.com --recursive
        - echo S3 bucket is cleared.
 
artifacts:
    files:
        - '**/*'
    base-directory: 'dist'

Any solution will be much appreciated. Thanks in advance

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I see you are trying to run main js file which is generated after build in case of ssr. To run that you need a script or Procfile as per aws documentation. To do this I added Procfile to my s3 bucket and then run the build command

buildspec file

  build:
    commands:
        - echo Build started 
        - npm run build:ssr
  post_build:
    commands:
        - aws s3 cp s3://yourbucketname/Procfile ./dist
        - bash -c "if [ /"$CODEBUILD_BUILD_SUCCEEDING/" == /"0/" ]; then exit 1; fi"
        # - aws s3 rm s3://devemr.growthemr.com --recursive
        - echo S3 bucket is cleared.
        # - aws cloudfront create-invalidation --distribution-id=E26GLI30EJTNBB --paths '/*'
 
artifacts:
    files:
        - '**/*'
    base-directory: 'dist'

Also, don't forget to add the permission in your s3 bucket like below

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::bucketname",
                "arn:aws:s3:::bucketname/*"
            ]
        }
    ]
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda