Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility of Amplify CD with npm 9 #3549

Closed
5 tasks done
mohammedsahl opened this issue Jun 22, 2023 · 3 comments
Closed
5 tasks done

Compatibility of Amplify CD with npm 9 #3549

mohammedsahl opened this issue Jun 22, 2023 · 3 comments
Assignees
Labels
archived This issue has been locked. custom-build-image question Further information is requested

Comments

@mohammedsahl
Copy link

mohammedsahl commented Jun 22, 2023

Before opening, please confirm:

  • I have checked to see if my question is addressed in the FAQ.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

App Id

d2d6ty1wlg8jch

AWS Region

us-east-1

Amplify Hosting feature

Build settings, Deployments, Frontend builds

Frontend framework

Angular

Next.js version

N/A

Next.js router

N/A

Describe the bug

Amplify CD fails when trying to patch Amplify CLI to 12.0.3. This started after our build image upgraded the version of npm being used to 9

Expected behavior

The build runs to completion without failing

Reproduction steps

  1. Create a custom build image. The image must use npm version 9
  2. Upload image to an Elastic Container Registry. Copy URI of image
  3. In AWS Amplify -> Build settings. In Build image settings set Custom image to URI from previous step
  4. Deploy app.

Build Settings

version: [VERSION-NUMBER]
backend:
  phases:
    preBuild:
      commands:
        - ./amplify-deploy-backend.sh
    build:
      commands:
        - amplifyPush --simple

frontend:
  phases:
    build:
      commands:
        - frontend/amplify-deploy-frontend.sh
  artifacts:
    baseDirectory: frontend/dist/amplify
    files:
      - '**/*'
  cache:
    paths:
      - 'frontend/node_modules/**/*'
      - 'node_modules/**/*'

Log output

# Put your logs below this line
2023-06-22T15:45:42.639Z [INFO]: Git SSH Key acquired
2023-06-22T15:45:42.742Z [INFO]: # Cloning repository: git@gitlab.com:user/repo.git
2023-06-22T15:45:46.656Z [INFO]: Agent pid 157
2023-06-22T15:45:46.740Z [INFO]: Identity added: /root/.ssh/git_rsa (/root/.ssh/git_rsa)
                                 Cloning into 'repo'...
                                 Warning: Permanently added the ECDSA host key for IP address '172.65.251.78' to the list of known hosts.
2023-06-22T15:45:46.741Z [INFO]: # Switching to commit: [COMMIT-HASH]
2023-06-22T15:45:46.894Z [INFO]: Agent pid 170
2023-06-22T15:45:46.895Z [INFO]: Identity added: /root/.ssh/git_rsa (/root/.ssh/git_rsa)
                                 Note: switching to '[COMMIT-HASH]'.
                                 You are in 'detached HEAD' state. You can look around, make experimental
                                 changes and commit them, and you can discard any commits you make in this
                                 state without impacting any branches by switching back to a branch.
                                 If you want to create a new branch to retain commits you create, you may
                                 do so (now or later) by using -c with the switch command. Example:
                                 git switch -c <new-branch-name>
                                 Or undo this operation with:
                                 git switch -
                                 Turn off this advice by setting config variable advice.detachedHead to false
                                 HEAD is now at [SHORT-COMMIT-HASH] remove spaces added to trigger backend-name graphql/pt lambda push
2023-06-22T15:45:46.905Z [INFO]: Successfully cleaned up Git credentials
2023-06-22T15:45:46.906Z [INFO]: # Checking for Git submodules at: /codebuild/output/src654124366/src/repo/.gitmodules
2023-06-22T15:45:46.912Z [INFO]: # Retrieving environment cache...
2023-06-22T15:45:46.965Z [INFO]: # Retrieved environment cache
2023-06-22T15:45:46.965Z [INFO]: ---- Setting Up SSM Secrets ----
2023-06-22T15:45:46.965Z [INFO]: SSM params {"Path":"/amplify/hash/backend-name/","WithDecryption":true}
2023-06-22T15:45:47.024Z [INFO]: # Determining if there are buildable backend changes in the amplify directory of the repository...
2023-06-22T15:45:47.037Z [INFO]: # Last built commit: [COMMIT-HASH]
2023-06-22T15:45:47.046Z [INFO]: # No differences detected.
2023-06-22T15:45:47.055Z [WARNING]: Command failed: source ~/.bashrc 2> /dev/null || true && nvm current
2023-06-22T15:45:47.056Z [INFO]: # Patching NPM package '@aws-amplify/cli' to 12.0.3...
2023-06-22T15:45:47.317Z [INFO]: npm
2023-06-22T15:45:47.318Z [INFO]: ERR! `user` is not a valid npm option
2023-06-22T15:45:47.319Z [INFO]: 
2023-06-22T15:45:47.320Z [INFO]: npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-06-22T15_45_47_248Z-debug-0.log
2023-06-22T15:45:47.322Z [ERROR]: !!! Error patching NPM package '@aws-amplify/cli' to version 12.0.3. Verify the package name and version are correct, and retry the build. For help see our docs: https://docs.aws.amazon.com/amplify/latest/userguide/custom-build-image.html
2023-06-22T15:45:47.323Z [WARNING]: ! Unable to patch packages...
2023-06-22T15:45:47.323Z [INFO]: # Starting environment caching...
2023-06-22T15:45:47.323Z [INFO]: # Uploading environment cache artifact...
2023-06-22T15:45:47.425Z [INFO]: # Uploaded environment cache artifact
2023-06-22T15:45:47.425Z [INFO]: # Environment caching completed

Additional information

I suspect it has something to do with this

@Jay2113 Jay2113 self-assigned this Jun 26, 2023
@Jay2113 Jay2113 added the question Further information is requested label Jul 14, 2023
@Jay2113
Copy link
Contributor

Jay2113 commented Feb 14, 2024

Hi @mohammedsahl 👋 , thanks for reaching out. I observed that the latest builds on your Amplify app d2d6ty1wlg8jch have completed successfully. Also, I wasn't able to reproduce the outlined behavior when using a custom build image with npm v9. By default, the Amazon Linux:2023 build image has npm v9 and Amplify CLI v12.8.2 installed. Now, if you add a live package override to set the Amplify CLI package to the latest version, the patching does complete successfully at build time:

# Patching NPM package ‘@aws-amplify/cli’ from 12.8.2 to 12.10.1...
2024-02-14T19:35:38.559Z [INFO]: # Installed ‘@aws-amplify/cli@12.10.1’
2024-02-14T19:35:38.711Z [INFO]: # Done patching NPM package ‘@aws-amplify/cli’ to version 12.10.1

I see that your app is using a custom image hosted on Amazon ECR and the root cause seems related to the npm configuration on the custom image. Its very likely that this breaking change introduced with npm v9 led to the patching to fail.

I am going to close this thread since the latest builds have succeeded.

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Copy link

This issue has been automatically locked.

@github-actions github-actions bot added the archived This issue has been locked. label Feb 14, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. custom-build-image question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants