amplify-backend icon indicating copy to clipboard operation
amplify-backend copied to clipboard

Sandbox doesn't seem to work. SyntaxError: Named export 'OperationTypeNode' not found.

Open ChrisDean opened this issue 4 months ago • 8 comments

Environment information

(.venv) # npx ampx info
file:///<my_path>/test/node_modules/@graphql-codegen/core/node_modules/@graphql-tools/merge/node_modules/@theguild/federation-composition/esm/subgraph/state.js:1
import { Kind, OperationTypeNode, specifiedScalarTypes, DirectiveLocation, } from "graphql";
               ^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'OperationTypeNode' not found. The requested module 'graphql' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'graphql';
const { Kind, OperationTypeNode, specifiedScalarTypes, DirectiveLocation, } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:220:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:321:5)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Node.js v22.17.0

Describe the bug

I appreciate this isn't exactly the expected output for npx ampx info but I'm simply trying to get the most basic project setup and running. In a totally vanilla environment I install the latest lts version of node, awscli and the basics for amplify

I run npm create amplify@latest Which seems to install a project fine then asks me to run ````npx ampx sandbox ``` which gives me the error above.

If I try some sample projects from the aws samples I get the same error.

I've tried adding type module to the package.json too as the docs suggest.

have also tried pinning the version of graphql to the latest version, this seems to allow sandbox to run in part but ultimately the CDK stuff fails if I do that...

Any ideas? different package versions or node version recommended?

Something else?

Reproduction steps

in a new foolder

npm create amplify@latest
npx ampx sandbox

ChrisDean avatar Jul 17 '25 21:07 ChrisDean

Same issue

markhker avatar Jul 17 '25 21:07 markhker

Apparently a GraphQLTools update broke Amplify's build and it's being worked on #2900 ardatan/graphqltools#7290

filipesbragio avatar Jul 17 '25 21:07 filipesbragio

The workaround is to add:

"overrides": {
    "@graphql-tools/merge": "9.0.22"
  }

to your package json.

sobolk avatar Jul 17 '25 21:07 sobolk

We shipped a fix in @aws-amplify/[email protected] For those affected please run npm update @aws-amplify/form-generator.

sobolk avatar Jul 17 '25 23:07 sobolk

Projects using Yarn 4.x are still affected. Re-opening.

sobolk avatar Jul 18 '25 14:07 sobolk

Projects using Yarn 4.x are still affected. Re-opening.

Thanks for your prompt work on this.

Can also confirm yarn berry failing from todays tests (I shifted back to npm for the time being as things seemed to work there on a fresh setup)

ChrisDean avatar Jul 18 '25 14:07 ChrisDean

The workaround for Yarn 4.x is to add the following to package.json and re-install deps.

  "resolutions": {
    "@graphql-tools/merge": "9.0.22"
  }

sobolk avatar Jul 18 '25 14:07 sobolk

We shipped another fix in '@aws-amplify/[email protected]'. It addresses Yarn 4.x.

sobolk avatar Jul 18 '25 20:07 sobolk