Amplify Hosting Env build fails on npm install

66 Views Asked by At

Im working on a project and pushed manually to my amplify backend until now and set up an hosting env connected to my github branch. But I receive the following error when the build starts via github:

2024-01-17T14:53:56.459Z [INFO]:  Received error [Error: Command failed with ENOENT: npm.cmd install --no-bin-links --production spawn npm.cmd ENOENT] running command [npm.cmd install --no-bin-links --production]

These are my build settings:

version: 1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: dist
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

and set the Amplify CLI to 12.10.1.

1

There are 1 best solutions below

2
Luke On

If you are pushing the backend manually, I presume you can be without the backend amplifypush --simple. Try this build.yml:

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

If this does not work, I would try omitting the cache part.