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

SyntaxError: TypeScript validation check failed. Resolution: Fix the syntax and type errors in your backend definition #1978

Closed
DeniseJames opened this issue Sep 10, 2024 · 4 comments
Labels
console-builds Issues related to Amplify console builds pending-triage Incoming issues that need categorization

Comments

@DeniseJames
Copy link

Environment information

C:\Users\Denise\Documents\amplify-social-room>npx ampx info
System:
  OS: Windows 10 10.0.19045
  CPU: (8) x64 Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz
  Memory: 2.59 GB / 7.95 GB
Binaries:
  Node: 18.18.0 - C:\Program Files\nodejs\node.EXE      
  Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD        
  npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/auth-construct: 1.3.0
  @aws-amplify/backend: 1.2.1
  @aws-amplify/backend-auth: 1.1.3
  @aws-amplify/backend-cli: 1.2.5
  @aws-amplify/backend-data: 1.1.3
  @aws-amplify/backend-deployer: 1.1.0
  @aws-amplify/backend-function: 1.4.0
  @aws-amplify/backend-output-schemas: 1.2.0
  @aws-amplify/backend-output-storage: 1.1.1
  @aws-amplify/backend-secret: 1.1.1
  @aws-amplify/backend-storage: 1.1.2
  @aws-amplify/cli-core: 1.1.2
  @aws-amplify/client-config: 1.3.0
  @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.1.0
  @aws-amplify/plugin-types: 1.2.1
  @aws-amplify/sandbox: 1.2.1
  @aws-amplify/schema-generator: 1.2.1
  aws-amplify: 6.6.0
  aws-cdk: 2.157.0
  aws-cdk-lib: 2.157.0
  typescript: 5.6.2
AWS environment variables:
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
  AWS_STS_REGIONAL_ENDPOINTS = regional
No CDK environment variables

Describe the bug

In deploying Amplify API, amplify-social-room. on AWS console I get a build error:

0

2024-09-10T11:09:23.871Z [INFO]: # Cloning repository: [email protected]:DeniseJames/amplify-social-room.git

1

2024-09-10T11:09:24.597Z [INFO]:

2

2024-09-10T11:09:24.597Z [INFO]: Cloning into 'amplify-social-room'...

3

2024-09-10T11:09:24.598Z [INFO]: # Switching to commit: 85fa5085a443b1867b6756dfa7540609fed4fdd3

4

2024-09-10T11:09:24.613Z [INFO]: Note: switching to '85fa5085a443b1867b6756dfa7540609fed4fdd3'.

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 85fa508 Update tsconfig.json

15

2024-09-10T11:09:24.676Z [INFO]: Successfully cleaned up Git credentials

16

2024-09-10T11:09:24.677Z [INFO]: # Checking for Git submodules at: /codebuild/output/src1406370740/src/amplify-social-room/.gitmodules

17

2024-09-10T11:09:24.685Z [INFO]: # Retrieving environment cache...

18

2024-09-10T11:09:24.748Z [INFO]: # Retrieved environment cache

19

2024-09-10T11:09:24.748Z [INFO]: ---- Setting Up SSM Secrets ----

20

2024-09-10T11:09:24.748Z [INFO]: SSM params {"Path":"/amplify/d4xya0ugb9ndf/main/","WithDecryption":true}

21

2024-09-10T11:09:25.421Z [INFO]: No live updates for this build run

22

2024-09-10T11:09:25.426Z [INFO]: # Retrieving cache...

23

2024-09-10T11:09:28.629Z [INFO]: # Extracting cache...

24

2024-09-10T11:09:30.073Z [INFO]: # Extraction completed

25

2024-09-10T11:09:30.104Z [INFO]: # Retrieved cache

26

2024-09-10T11:09:32.660Z [INFO]: ## Starting Backend Build

27

# Starting phase: build

28

# Executing command: npm ci --cache .npm --prefer-offline

29

2024-09-10T11:09:44.722Z [WARNING]: npm

30

2024-09-10T11:09:44.728Z [WARNING]: WARN ERESOLVE overriding peer dependency

31

npm WARN While resolving: [email protected]

32

npm WARN Found: [email protected]

33

npm WARN node_modules/graphql

34

npm WARN graphql@"^15.3.0" from the root project

35

npm WARN 26 more (@ardatan/relay-compiler, @graphql-codegen/core, ...)

36

npm WARN

37

npm WARN Could not resolve dependency:

38

npm WARN peer graphql@"0.11.7 || ^0.12.0 || ^0.13.0 || ^14.0.0" from [email protected]

39

npm WARN node_modules/aws-appsync/node_modules/apollo-cache-inmemory

40

npm WARN apollo-cache-inmemory@"1.3.12" from [email protected]

41

npm WARN node_modules/aws-appsync

42

npm WARN

43

npm WARN Conflicting peer dependency: [email protected]

44

npm WARN node_modules/graphql

45

npm WARN peer graphql@"0.11.7 || ^0.12.0 || ^0.13.0 || ^14.0.0" from [email protected]

46

npm WARN node_modules/aws-appsync/node_modules/apollo-cache-inmemory

47

npm WARN apollo-cache-inmemory@"1.3.12" from [email protected]

48

npm WARN node_modules/aws-appsync

49

2024-09-10T11:09:44.739Z [WARNING]: npm WARN ERESOLVE overriding peer dependency

50

npm WARN While resolving: [email protected]

51

npm WARN Found: [email protected]

52

npm WARN node_modules/graphql

53

npm WARN graphql@"^15.3.0" from the root project

54

npm WARN 26 more (@ardatan/relay-compiler, @graphql-codegen/core, ...)

55

npm WARN

56

npm WARN Could not resolve dependency:

57

npm WARN peer graphql@"^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0" from [email protected]

58

npm WARN node_modules/aws-appsync/node_modules/apollo-client

59

npm WARN apollo-client@"2.4.6" from [email protected]

60

npm WARN node_modules/aws-appsync

61

npm WARN 1 more (aws-appsync-subscription-link)

62

npm WARN

63

npm WARN Conflicting peer dependency: [email protected]

64

npm WARN node_modules/graphql

65

npm WARN peer graphql@"^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0" from [email protected]

66

npm WARN node_modules/aws-appsync/node_modules/apollo-client

67

npm WARN apollo-client@"2.4.6" from [email protected]

68

npm WARN node_modules/aws-appsync

69

npm WARN 1 more (aws-appsync-subscription-link)

70

2024-09-10T11:09:44.753Z [WARNING]: npm WARN ERESOLVE overriding peer dependency

71

2024-09-10T11:09:44.754Z [WARNING]: npm WARN While resolving: [email protected]

72

npm WARN Found: [email protected]

73

npm WARN node_modules/graphql

74

npm WARN graphql@"^15.3.0" from the root project

75

npm WARN 26 more (@ardatan/relay-compiler, @graphql-codegen/core, ...)

76

npm WARN

77

npm WARN

78

2024-09-10T11:09:44.754Z [WARNING]: Could not resolve dependency:

79

npm WARN peer graphql@"^0.11.3 || ^0.12.3 || ^0.13.0 || ^14.0.0" from [email protected]

80

npm WARN node_modules/aws-appsync/node_modules/apollo-link

81

npm WARN apollo-link@"1.2.5" from [email protected]

82

npm WARN node_modules/aws-appsync

83

npm WARN 3 more (apollo-client, apollo-link-http, aws-appsync-subscription-link)

84

npm WARN

85

npm WARN Conflicting peer dependency: [email protected]

86

npm WARN node_modules/graphql

87

npm WARN

88

2024-09-10T11:09:44.754Z [WARNING]: peer graphql@"^0.11.3 || ^0.12.3 || ^0.13.0 || ^14.0.0" from [email protected]

89

npm WARN node_modules/aws-appsync/node_modules/apollo-link

90

npm WARN apollo-link@"1.2.5" from [email protected]

91

npm WARN node_modules/aws-appsync

92

npm WARN 3 more (apollo-client, apollo-link-http, aws-appsync-subscription-link)

93

2024-09-10T11:09:44.760Z [WARNING]: npm WARN ERESOLVE overriding peer dependency

94

2024-09-10T11:09:44.760Z [WARNING]: npm WARN While resolving: [email protected]

95

npm WARN Found: [email protected]

96

npm WARN node_modules/graphql

97

npm WARN graphql@"^15.3.0" from the root project

98

npm WARN 26 more (@ardatan/relay-compiler, @graphql-codegen/core, ...)

99

npm WARN

100

npm WARN Could not resolve dependency:

101

npm WARN peer graphql@"^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0" from [email protected]

102

npm WARN node_modules/aws-appsync/node_modules/apollo-link-http

103

npm WARN apollo-link-http@"1.5.8" from [email protected]

104

npm WARN node_modules/aws-appsync

105

npm WARN 1 more (aws-appsync-subscription-link)

106

npm WARN

107

npm WARN Conflicting peer dependency: [email protected]

108

npm WARN node_modules/graphql

109

npm WARN peer graphql@"^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0" from [email protected]

110

npm WARN node_modules/aws-appsync/node_modules/apollo-link-http

111

npm WARN apollo-link-http@"1.5.8" from [email protected]

112

npm WARN node_modules/aws-appsync

113

npm WARN 1 more (aws-appsync-subscription-link)

114

2024-09-10T11:09:58.185Z [WARNING]: npm

115

2024-09-10T11:09:58.191Z [WARNING]: WARN deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.

116

2024-09-10T11:09:58.310Z [WARNING]: npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.

117

2024-09-10T11:09:58.479Z [WARNING]: npm WARN deprecated @humanwhocodes/[email protected]: Use @eslint/config-array instead

118

2024-09-10T11:09:58.501Z [WARNING]: npm WARN deprecated [email protected]: Rimraf versions prior to v4 are no longer supported

119

2024-09-10T11:09:58.827Z [WARNING]: npm WARN

120

2024-09-10T11:09:58.827Z [WARNING]: deprecated @humanwhocodes/[email protected]: Use @eslint/object-schema instead

121

2024-09-10T11:09:58.839Z [WARNING]: npm

122

2024-09-10T11:09:58.840Z [WARNING]: WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported

123

2024-09-10T11:09:58.849Z [WARNING]: npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported

124

2024-09-10T11:09:58.905Z [WARNING]: npm WARN deprecated

125

2024-09-10T11:09:58.905Z [WARNING]: @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.

126

2024-09-10T11:10:02.576Z [WARNING]: npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.

127

2024-09-10T11:10:12.219Z [WARNING]: npm

128

2024-09-10T11:10:12.224Z [WARNING]: WARN deprecated [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.

129

2024-09-10T11:10:14.785Z [INFO]: added 1213 packages, and audited 1340 packages in 35s

130

2024-09-10T11:10:14.786Z [INFO]: 171 packages are looking for funding

131

run `npm fund` for details

132

2024-09-10T11:10:14.787Z [INFO]: found 0 vulnerabilities

133

2024-09-10T11:10:14.820Z [INFO]: # Executing command: npx ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID

134

2024-09-10T11:10:21.105Z [INFO]:

135

2024-09-10T11:10:27.093Z [INFO]: amplify/backend.ts(3,10): error TS2305: Module '"./data/resource"' has no exported member 'data'.

136

2024-09-10T11:10:27.132Z [INFO]:

137

2024-09-10T11:10:27.132Z [WARNING]: ampx pipeline-deploy

138

Command to deploy backends in a custom CI/CD pipeline. This command is not inten

139

ded to be used locally.

140

Options:

141

--debug Print debug logs to the console [boolean] [default: false]

142

--help Show help [boolean]

143

--branch Name of the git branch being deployed [string] [required]

144

--app-id The app id of the target Amplify app [string] [required]

145

--outputs-out-dir A path to directory where amplify_outputs is written. If no

146

t provided defaults to current process working directory.

147

[string]

148

--outputs-version Version of the configuration. Version 0 represents classic

149

amplify-cli config file amplify-configuration and 1 represe

150

nts newer config file amplify_outputs

151

[string] [choices: "0", "1", "1.1"] [default: "1.1"]

152

--outputs-format amplify_outputs file format

153

[string] [choices: "mjs", "json", "json-mobile", "ts", "dart"]

154

2024-09-10T11:10:27.132Z [INFO]: SyntaxError: TypeScript validation check failed.

155

Resolution: Fix the syntax and type errors in your backend definition.

156

Cause: Command failed with exit code 2: npx tsc --noEmit --skipLibCheck --project amplify

157

2024-09-10T11:10:27.261Z [ERROR]: !!! Build failed

158

2024-09-10T11:10:27.262Z [ERROR]: !!! Error: Command failed with exit code 1

159

2024-09-10T11:10:27.262Z [INFO]: # Starting environment caching...

160

2024-09-10T11:10:27.262Z [INFO]: # Uploading environment cache artifact...

161

2024-09-10T11:10:27.333Z [INFO]: # Uploaded environment cache artifact

162

2024-09-10T11:10:27.333Z [INFO]: # Environment caching completed

163


Reproduction steps

I upload the code from a github repo produced in visual studio code. My backend path C:\Users\Denise\Documents\amplify-social-room\amplify\backend\api\MyAppSyncAPI\build\schema.graphql only has one file schema.graphql

This is my backend-config.json file

{
"api": {}
}

There are no ts files. What am I missing?

@DeniseJames DeniseJames added the pending-triage Incoming issues that need categorization label Sep 10, 2024
@ykethan
Copy link
Member

ykethan commented Sep 10, 2024

Hey @DeniseJames, just to ensure is this a Amplify Gen 1 application?
if yes, I would suggest switching the deploy command npx ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID on the amplify.yml in the build setting or if present in your repository to amplifyPush --simple, as the deploy command is a Amplify Gen 2 command.

@ykethan ykethan added pending-response Issue is pending response from author console-builds Issues related to Amplify console builds labels Sep 10, 2024
@DeniseJames
Copy link
Author

@ykethan This is a Gen 2 application.

@github-actions github-actions bot removed the pending-response Issue is pending response from author label Sep 10, 2024
@ykethan
Copy link
Member

ykethan commented Sep 10, 2024

Hey @DeniseJames, could you provide some information on how the application was setup?
as files such as schema.graphql and backend-config.json specific to Amplify Gen 1 which follows a different paradigm in creating your backend resources.

@ykethan ykethan added the pending-response Issue is pending response from author label Sep 10, 2024
@DeniseJames
Copy link
Author

DeniseJames commented Sep 10, 2024

I found the one syntax error by running this
npx tsc --noEmit --skipLibCheck --project amplify

@github-actions github-actions bot removed the pending-response Issue is pending response from author label Sep 10, 2024
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

2 participants