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

Module not found: Error: Can't resolve './graphql' #7744

Closed
omenking opened this issue Feb 13, 2021 · 5 comments
Closed

Module not found: Error: Can't resolve './graphql' #7744

omenking opened this issue Feb 13, 2021 · 5 comments
Labels
to-be-reproduced Used in order for Amplify to reproduce said issue

Comments

@omenking
Copy link

omenking commented Feb 13, 2021

I am experincing this error:

ERROR in ./node_modules/graphql/index.mjs 34:0-49
Module not found: Error: Can't resolve './graphql' in '/Users/andrewbrown/Sites/banana-brigade/node_modules/graphql'
Did you mean 'graphql.js'?
BREAKING CHANGE: The request './graphql' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 90:0-39 221:41-53 345:49-61 503:37-49 519:46-58 543:37-49
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

I have imported the following:

  "dependencies": {
   "@aws-amplify/auth": "^3.4.21",
   "@aws-amplify/core": "^3.8.13",
   "@aws-amplify/datastore": "^2.9.7",

It is occurring I believe when I attempt to save a model:

    const model = DataStore.save(
      new Banana({
        cognito_uuid: cognito_uuid,
        vector: vector
      })
    )
    console.log(model)
    model.save()

I have a public repo. I have tagged the commit so you can replicate it in the exact state this is happening in:
https://github.com/omenking/banana-brigade/tree/0.0.1

I do have deployed infrastructure via the Admin UI, which is linked via the awsconfig.yml.

I have not pulled my backend code because it is my attempt to keep as much code out of my repo as possible.
I don't know if this is the cause of this error

Similar error in this ticket #7538 but not much insight to help solve my issue

My node_modules does contain graphql

Screen Shot 2021-02-13 at 9 02 56 AM

I thought maybe it wants @aws-amplify/pubsub but that is not the case.

@omenking omenking added the to-be-reproduced Used in order for Amplify to reproduce said issue label Feb 13, 2021
@omenking
Copy link
Author

Here's the full log

WARNING in ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 221:41-53
export 'GraphQLError' (imported as 'GraphQLError') was not found in 'graphql' (module has no exports)
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

WARNING in ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 345:49-61
export 'GraphQLError' (imported as 'GraphQLError') was not found in 'graphql' (module has no exports)
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

WARNING in ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 503:37-49
export 'GraphQLError' (imported as 'GraphQLError') was not found in 'graphql' (module has no exports)
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

WARNING in ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 519:46-58
export 'GraphQLError' (imported as 'GraphQLError') was not found in 'graphql' (module has no exports)
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

WARNING in ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 543:37-49
export 'GraphQLError' (imported as 'GraphQLError') was not found in 'graphql' (module has no exports)
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

WARNING in ./node_modules/amazon-cognito-identity-js/es/utils/cryptoSecureRandomInt.js 20:13-30
Module not found: Error: Can't resolve 'crypto' in '/Users/andrewbrown/Sites/banana-brigade/node_modules/amazon-cognito-identity-js/es/utils'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
	- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "crypto": false }
 @ ./node_modules/amazon-cognito-identity-js/es/utils/WordArray.js 1:0-60 43:17-38
 @ ./node_modules/amazon-cognito-identity-js/es/AuthenticationHelper.js 23:0-42 26:25-34
 @ ./node_modules/amazon-cognito-identity-js/es/index.js 18:0-73 18:0-73
 @ ./node_modules/@aws-amplify/auth/lib-esm/index.js 15:0-99 21:0-122 21:0-122 21:0-122
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/processors/subscription.js 69:0-37 206:49-72 218:49-68 239:53-82
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 78:0-79 115:42-63 177:80-101
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

1 warning has detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

ERROR in ./node_modules/graphql/index.mjs 34:0-49
Module not found: Error: Can't resolve './graphql' in '/Users/andrewbrown/Sites/banana-brigade/node_modules/graphql'
Did you mean 'graphql.js'?
BREAKING CHANGE: The request './graphql' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 90:0-39 221:41-53 345:49-61 503:37-49 519:46-58 543:37-49
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

ERROR in ./node_modules/graphql/index.mjs 36:0-47:50
Module not found: Error: Can't resolve './type' in '/Users/andrewbrown/Sites/banana-brigade/node_modules/graphql'
Did you mean 'index.js'?
BREAKING CHANGE: The request './type' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 90:0-39 221:41-53 345:49-61 503:37-49 519:46-58 543:37-49
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

ERROR in ./node_modules/graphql/index.mjs 49:0-53:205
Module not found: Error: Can't resolve './language' in '/Users/andrewbrown/Sites/banana-brigade/node_modules/graphql'
Did you mean 'index.js'?
BREAKING CHANGE: The request './language' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 90:0-39 221:41-53 345:49-61 503:37-49 519:46-58 543:37-49
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

ERROR in ./node_modules/graphql/index.mjs 55:0-101
Module not found: Error: Can't resolve './execution' in '/Users/andrewbrown/Sites/banana-brigade/node_modules/graphql'
Did you mean 'index.js'?
BREAKING CHANGE: The request './execution' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 90:0-39 221:41-53 345:49-61 503:37-49 519:46-58 543:37-49
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

ERROR in ./node_modules/graphql/index.mjs 56:0-68
Module not found: Error: Can't resolve './subscription' in '/Users/andrewbrown/Sites/banana-brigade/node_modules/graphql'
Did you mean 'index.js'?
BREAKING CHANGE: The request './subscription' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 90:0-39 221:41-53 345:49-61 503:37-49 519:46-58 543:37-49
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

ERROR in ./node_modules/graphql/index.mjs 58:0-60:675
Module not found: Error: Can't resolve './validation' in '/Users/andrewbrown/Sites/banana-brigade/node_modules/graphql'
Did you mean 'index.js'?
BREAKING CHANGE: The request './validation' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 90:0-39 221:41-53 345:49-61 503:37-49 519:46-58 543:37-49
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

ERROR in ./node_modules/graphql/index.mjs 62:0-64
Module not found: Error: Can't resolve './error' in '/Users/andrewbrown/Sites/banana-brigade/node_modules/graphql'
Did you mean 'index.js'?
BREAKING CHANGE: The request './error' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 90:0-39 221:41-53 345:49-61 503:37-49 519:46-58 543:37-49
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

ERROR in ./node_modules/graphql/index.mjs 64:0-98:42
Module not found: Error: Can't resolve './utilities' in '/Users/andrewbrown/Sites/banana-brigade/node_modules/graphql'
Did you mean 'index.js'?
BREAKING CHANGE: The request './utilities' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider.js 90:0-39 221:41-53 345:49-61 503:37-49 519:46-58 543:37-49
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/Providers/index.js 15:0-45 15:0-45
 @ ./node_modules/@aws-amplify/pubsub/lib-esm/index.js 14:0-28 14:0-28
 @ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 69:0-72 625:16-52 626:16-53
 @ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
 @ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
 @ ./src/index.js 4:0-51 38:16-30

8 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.21.2 compiled with 8 errors and 6 warnings in 3242 ms
ℹ 「wdm」: Failed to compile.

@omenking
Copy link
Author

Reading about this graphql/graphql-js#2721

I added this to rule and almost all errors are gone:

  module: {
    rules: [
      {
        test: /\.m?js/,
        resolve: {
          fullySpecified: false
        }
      },

with the exception of this error:

WARNING in ./node_modules/amazon-cognito-identity-js/es/utils/cryptoSecureRandomInt.js 20:13-30
Module not found: Error: Can't resolve 'crypto' in '/Users/andrewbrown/Sites/banana-brigade/node_modules/amazon-cognito-identity-js/es/utils'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
   - add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
   - install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
   resolve.fallback: { "crypto": false }
@ ./node_modules/amazon-cognito-identity-js/es/utils/WordArray.js 1:0-60 43:17-38
@ ./node_modules/amazon-cognito-identity-js/es/AuthenticationHelper.js 23:0-42 26:25-34
@ ./node_modules/amazon-cognito-identity-js/es/index.js 18:0-73 18:0-73
@ ./node_modules/@aws-amplify/auth/lib-esm/index.js 15:0-99 21:0-122 21:0-122 21:0-122
@ ./node_modules/@aws-amplify/datastore/lib-esm/sync/processors/subscription.js 69:0-37 206:49-72 218:49-68 239:53-82
@ ./node_modules/@aws-amplify/datastore/lib-esm/sync/index.js 78:0-79 115:42-63 177:80-101
@ ./node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js 92:0-53 131:24-47 519:40-50 529:38-83 530:38-83
@ ./node_modules/@aws-amplify/datastore/lib-esm/index.js 1:0-78 1:0-78 1:0-78 1:0-78
@ ./src/index.js 4:0-51 38:16-30

1 warning has detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.21.2 compiled with 1 warning in 3560 ms
ℹ 「wdm」: Compiled with warnings.

@omenking
Copy link
Author

resolve: {
fallback: {
"crypto": false
}
},

@cybercussion
Copy link

Which files are we editing here to put either the rules or the resolve snippets in? There are like a billion config files lol

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
to-be-reproduced Used in order for Amplify to reproduce said issue
Projects
None yet
Development

No branches or pull requests

2 participants