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

Deployments Failing with "Cannot Find Module @aws-sdk/*" after Version Bumps (React Native - Expo Managed Workflow) #1922

Closed
ChristopherGabba opened this issue Aug 27, 2024 · 3 comments
Labels
console-builds Issues related to Amplify console builds pending-triage Incoming issues that need categorization

Comments

@ChristopherGabba
Copy link

Environment information

OS: macOS 14.5
  CPU: (10) arm64 Apple M2 Pro
  Memory: 620.97 MB / 16.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 22.7.0 - /opt/homebrew/bin/node
  Yarn: 1.22.22 - /opt/homebrew/bin/yarn
  npm: 10.8.2 - /opt/homebrew/bin/npm
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/auth-construct: 1.3.0
  @aws-amplify/backend: 1.1.1
  @aws-amplify/backend-auth: 1.1.3
  @aws-amplify/backend-cli: 1.2.5
  @aws-amplify/backend-data: 1.1.2
  @aws-amplify/backend-deployer: 1.1.0
  @aws-amplify/backend-function: 1.3.4
  @aws-amplify/backend-output-schemas: 1.2.0
  @aws-amplify/backend-output-storage: 1.1.1
  @aws-amplify/backend-secret: 1.1.0
  @aws-amplify/backend-storage: 1.1.2
  @aws-amplify/cli-core: 1.1.2
  @aws-amplify/client-config: 1.2.1
  @aws-amplify/deployed-backend-client: 1.4.0
  @aws-amplify/form-generator: 1.0.1
  @aws-amplify/model-generator: 1.0.5
  @aws-amplify/platform-core: 1.0.6
  @aws-amplify/plugin-types: 1.2.1
  @aws-amplify/sandbox: 1.2.0
  @aws-amplify/schema-generator: 1.2.1
  aws-amplify: 6.5.2
  aws-cdk: 2.154.1
  aws-cdk-lib: 2.154.1
  typescript: 5.3.3
AWS environment variables:
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables

Description

I made a few package version bumps:

  -   "@aws-amplify/backend-cli": "^1.0.2",
  -   "@aws-amplify/react-native": "^1.1.0",
  -   "@aws-amplify/ui-react-native": "^2.2.0",
  +   "@aws-amplify/backend-cli": "^1.2.4",
  +   "@aws-amplify/react-native": "^1.1.4",
  +   "@aws-amplify/ui-react-native": "^2.2.5",

   -  "aws-amplify": "^6.5.0",
   +  "aws-amplify": "^6.5.2",

And for the last few days since then, every one of my Gen 2 deployments has failed with a Cannot Find Module @aws-sdk* type of error:
image

Screenshot 2024-08-27 at 8 23 48 AM

At first I thought, oh maybe I need to add that package now as a result of the version bump. So I will run yarn add @aws-sdk/*package-name* then I get another package. I added around 10 packages and kept getting more and realized something must be wrong. When I do install that particular package, the error then changes to a different package.

Here is the actual full deployment failure log:

2024-08-25T13:50:07.491Z [INFO]: # Cloning repository: [email protected]:ChristopherGabba/ReelFeelApp.git

1

2024-08-25T13:50:08.953Z [INFO]:

2

2024-08-25T13:50:08.954Z [INFO]: Cloning into 'ReelFeelApp'...

3

2024-08-25T13:50:08.954Z [INFO]: # Switching to commit: fa1e19fcf21d05f4dd599665d208965008ba5bec

4

2024-08-25T13:50:09.002Z [INFO]: Note: switching to 'fa1e19fcf21d05f4dd599665d208965008ba5bec'.

5

You are in 'detached HEAD' state. You can look around, make experimental

6

changes and commit them, and you can discard any commits you make in this

7

state without impacting any branches by switching back to a branch.

8

If you want to create a new branch to retain commits you create, you may

9

do so (now or later) by using -c with the switch command. Example:

10

git switch -c <new-branch-name>

11

Or undo this operation with:

12

git switch -

13

Turn off this advice by setting config variable advice.detachedHead to false

14

HEAD is now at fa1e19f fix: upload progress accuracy improvement

15

2024-08-25T13:50:09.098Z [INFO]: Successfully cleaned up Git credentials

16

2024-08-25T13:50:09.098Z [INFO]: # Checking for Git submodules at: /codebuild/output/src3924304060/src/ReelFeelApp/.gitmodules

17

2024-08-25T13:50:09.109Z [INFO]: # Retrieving environment cache...

18

2024-08-25T13:50:09.176Z [INFO]: # Retrieved environment cache

19

2024-08-25T13:50:09.176Z [INFO]: ---- Setting Up SSM Secrets ----

20

2024-08-25T13:50:09.176Z [INFO]: SSM params {"Path":"/amplify/d3oatah55ad2xi/master/","WithDecryption":true}

21

2024-08-25T13:50:10.224Z [INFO]: No live updates for this build run

22

2024-08-25T13:50:10.258Z [INFO]: # Retrieving cache...

23

2024-08-25T13:50:24.955Z [INFO]: # Extracting cache...

24

2024-08-25T13:51:10.793Z [INFO]: # Extraction completed

25

2024-08-25T13:51:11.022Z [INFO]: # Retrieved cache

26

2024-08-25T13:51:15.395Z [INFO]: ## Starting Backend Build

27

# Starting phase: build

28

# Executing command: yarn install

29

2024-08-25T13:51:17.372Z [INFO]: yarn install v1.22.19

30

2024-08-25T13:51:17.678Z [INFO]: [1/5] Validating package.json...

31

2024-08-25T13:51:17.685Z [INFO]: [2/5] Resolving packages...

32

2024-08-25T13:51:18.402Z [INFO]: [3/5] Fetching packages...

33

2024-08-25T13:52:13.339Z [INFO]: [4/5] Linking dependencies...

34

2024-08-25T13:52:13.345Z [WARNING]: warning " > @aws-amplify/[email protected]" has unmet peer dependency "@aws-sdk/types@^3.609.0".

35

warning "@aws-amplify/backend-cli > @aws-amplify/[email protected]" has unmet peer dependency "@aws-sdk/types@^3.609.0".

36

2024-08-25T13:52:13.346Z [WARNING]: warning "@aws-amplify/backend-cli > @aws-sdk/[email protected]" has unmet peer dependency "@aws-sdk/client-sts@^3.637.0".

37

warning "@aws-amplify/backend > @aws-amplify/[email protected]" has unmet peer dependency "@aws-sdk/types@^3.609.0".

38

2024-08-25T13:52:13.347Z [WARNING]: warning "@aws-amplify/backend-cli > @aws-sdk/credential-provider-ini > @aws-sdk/[email protected]" has unmet peer dependency "@aws-sdk/client-sts@^3.621.0".

39

2024-08-25T13:52:13.355Z [WARNING]: warning "@aws-amplify/backend-cli > @aws-sdk/credential-provider-ini > @aws-sdk/credential-provider-sso > @aws-sdk/[email protected]" has unmet peer dependency "@aws-sdk/client-sso-oidc@^3.614.0".

40

2024-08-25T13:52:13.361Z [WARNING]: warning " > [email protected]" has incorrect peer dependency "[email protected]".

41

2024-08-25T13:53:02.474Z [INFO]: [5/5] Building fresh packages...

42

2024-08-25T13:53:06.581Z [INFO]: $ patch-package

43

2024-08-25T13:53:06.803Z [INFO]: patch-package 6.4.7

44

2024-08-25T13:53:06.803Z [INFO]: Applying patches...

45

2024-08-25T13:53:06.809Z [INFO]: [email protected] ✔

46

2024-08-25T13:53:06.819Z [INFO]: Done in 109.45s.

47

2024-08-25T13:53:06.869Z [INFO]: # Executing command: yarn ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID

48

2024-08-25T13:53:07.037Z [INFO]: yarn run v1.22.19

49

2024-08-25T13:53:07.066Z [INFO]: $ /codebuild/output/src3924304060/src/ReelFeelApp/node_modules/.bin/ampx pipeline-deploy --branch master --app-id d3oatah55ad2xi

50

2024-08-25T13:53:09.238Z [WARNING]: node:internal/modules/cjs/loader:1077

51

const err = new Error(message);

52

^

53

Error: Cannot find module '@aws-sdk/protocol-http'

54

Require stack:

55

- /codebuild/output/src3924304060/src/ReelFeelApp/node_modules/@aws-sdk/client-iam/node_modules/@aws-sdk/middleware-host-header/dist-cjs/index.js

56

- /codebuild/output/src3924304060/src/ReelFeelApp/node_modules/@aws-sdk/client-iam/dist-cjs/index.js

57

- /codebuild/output/src3924304060/src/ReelFeelApp/node_modules/@aws-amplify/graphql-schema-generator/lib/utils/vpc-helper.js

58

at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)

59

at Module._load (node:internal/modules/cjs/loader:922:27)

60

at Module.require (node:internal/modules/cjs/loader:1143:19)

61

at require (node:internal/modules/cjs/helpers:119:18)

62

at Object.<anonymous> (/codebuild/output/src3924304060/src/ReelFeelApp/node_modules/@aws-sdk/client-iam/node_modules/@aws-sdk/middleware-host-header/dist-cjs/index.js:4:25)

63

at Module._compile (node:internal/modules/cjs/loader:1256:14)

64

at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)

65

at Module.load (node:internal/modules/cjs/loader:1119:32)

66

at Module._load (node:internal/modules/cjs/loader:960:12)

67

at Module.require (node:internal/modules/cjs/loader:1143:19) {

68

code: 'MODULE_NOT_FOUND',

69

requireStack: [

70

'/codebuild/output/src3924304060/src/ReelFeelApp/node_modules/@aws-sdk/client-iam/node_modules/@aws-sdk/middleware-host-header/dist-cjs/index.js',

71

'/codebuild/output/src3924304060/src/ReelFeelApp/node_modules/@aws-sdk/client-iam/dist-cjs/index.js',

72

'/codebuild/output/src3924304060/src/ReelFeelApp/node_modules/@aws-amplify/graphql-schema-generator/lib/utils/vpc-helper.js'

73

]

74

}

75

2024-08-25T13:53:09.239Z [WARNING]: Node.js v18.18.2

76

2024-08-25T13:53:09.258Z [WARNING]: error Command failed with exit code 1.

77

2024-08-25T13:53:09.258Z [INFO]: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

78

2024-08-25T13:53:09.276Z [ERROR]: !!! Build failed

79

2024-08-25T13:53:09.276Z [ERROR]: !!! Error: Command failed with exit code 1

80

2024-08-25T13:53:09.277Z [INFO]: # Starting environment caching...

81

2024-08-25T13:53:09.277Z [INFO]: # Uploading environment cache artifact...

82

2024-08-25T13:53:09.364Z [INFO]: # Uploaded environment cache artifact

83

2024-08-25T13:53:09.365Z [INFO]: # Environment caching completed

All the research I found seems to indicate some issue with the node installation. I've tried:

  • Doing a complete uninstall and reinstall of node
  • Deleting node_modules and yarn_lock and reinstalling everything

Neither worked.

Here is my amplify.yml:

version: 1
backend:
  phases:
    build:
      commands:
        - yarn install
        - yarn ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID
frontend:
  phases:
    build:
      commands:
        - mkdir ./dist && touch ./dist/index.html
  artifacts:
    baseDirectory: dist
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
      - .npm/**/*
@ChristopherGabba ChristopherGabba added the pending-triage Incoming issues that need categorization label Aug 27, 2024
@Jay2113 Jay2113 added the console-builds Issues related to Amplify console builds label Aug 27, 2024
@Jay2113
Copy link

Jay2113 commented Aug 28, 2024

Hi @ChristopherGabba 👋 , thanks for raising this! Can you upgrade the packages to the latest versions?

@aws-amplify/backend - 1.2.0
@aws-amplify/backend-cli - 1.2.5
@aws-amplify/react-native - 1.1.4
@aws-amplify/ui-react-native - 2.2.5
aws-amplify - 6.5.3

Additionally, you can try excluding the cache section from the amplify.yml file to ensure that older node_modules aren't persistented during the build.

@Jay2113 Jay2113 added the pending-response Issue is pending response from author label Aug 28, 2024
@ChristopherGabba
Copy link
Author

@Jay2113 You are the man, that fixed it!

Solution for anyone who stumbles across this:

  • Ran yarn upgrade per @ykethan 's Discord advice
  • Upgraded packages to latest versions per @Jay2113 's advice
  • Removed the cache section of my amplify.yml

Not sure which of these solutions was actually the fix, or a combination.

Closing the issue.

@github-actions github-actions bot removed the pending-response Issue is pending response from author label Aug 28, 2024
@myyk
Copy link

myyk commented Sep 18, 2024

I had a very similar issue, for me it was only the clearing the "removing the cache section of my amplify.yml" that fixed my deployment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
console-builds Issues related to Amplify console builds pending-triage Incoming issues that need categorization
Projects
None yet
Development

No branches or pull requests

3 participants