skip to Main Content

I have build an small web application with node js express with html and css which starts from the below command in npm start app.js but the same thing doesnot work in aws amplify in order to launch this as serverless application.

Here is the log for the build phase in aws amplify.

# Starting phase: preBuild
                                 # Executing command: rm -r node_modules
2022-08-11T13:02:59.128Z [INFO]: # Executing command: npm ci
2022-08-11T13:03:05.392Z [INFO]: added 173 packages in 5.946s

Here is the amplify.yml

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - rm -r node_modules
        - npm ci
    # IMPORTANT - Please verify your build commands
    build:
      commands:
        - npm start app.js

Please suggest.

2

Answers


  1. Chosen as BEST ANSWER

    version: 1
    frontend:
      phases:
        preBuild:
          commands:
            - npm ci
        build:
          commands:
            - npm run build
      artifacts:
        baseDirectory: dist
        files:
          - '**/*'
      cache:
        paths:
          - node_modules/**/*

    This is the yml file which will lead worked for me in order to build the packages in npm and run in aws amplify.


  2. I had exact the same issue.

    You should first try executing the exact command on your local computer.
    In my case, the consecutive command was showing a prompt and that was why the build process was stuck there forever.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search