const GraphQLUpload = require("graphql-upload/GraphQLUpload.mjs") error but i dont use require
See original GitHub issueimport * as GraphQLUpload from ‘graphql-upload/GraphQLUpload.mjs’; import type { FileUpload } from ‘graphql-upload/processRequest.mjs’;
Error
const GraphQLUploadError [ERR_REQUIRE_ESM]: require() of ES Module CarRent\server\node_modules\graphql-upload\GraphQLUpload.mjs not supported.
Instead change the require of CarRent\server\node_modules\graphql-upload\GraphQLUpload.mjs to a dynamic import() which is available in all CommonJS modules. = require("graphql-upload/GraphQLUpload.mjs")
Pleace help
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
File uploads not working with graphql-upload package #901
When you request the mutation as displayed in the tutorial, the request returns an error not liking the null value in the operation....
Read more >GraphQL getting error "Upload" is not defined in schema but ...
In my backend app built with NodeJS and GraphQL, I'm getting the below error but I have no clue what does it mean....
Read more >graphql-upload | Yarn - Package Manager
Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers....
Read more >graphql-upload - npm
A schema built with separate SDL and resolvers (e.g. using the function makeExecutableSchema from @graphql-tools/schema ) requires the Upload ...
Read more >Migrating to Apollo Server 4 - Apollo GraphQL Docs
Instead, there's a single ApolloServer class with a single API that all integrations use. In Apollo Server 3, the Apollo Server core team...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t think so. The TS config looks better, but I’m not sure what you’re doing with the code.
If you want to dynamic import an ES module, perhaps because the surrounding module is CJS, you need to do this:
Note that you will run into problems with top level
await
in a CJS module so you will need to put that in an async function or use.then()
syntax.But you can use a regular import if you have TS configured to emit ES modules:
This stuff is just general advice around how native JavaScript works, which is beyond the scope of
graphql-upload
maintenance. I’m happy to help a little bit with general JavaScript advice, but keep in mind I don’t always have the time.Here is the MDN article on dynamic import:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import
Here is a TypeScript article on ESM in Node.js:
https://www.typescriptlang.org/docs/handbook/esm-node.html
Here is the Node.js docs on ESM:
https://nodejs.org/dist/latest-v19.x/docs/api/esm.html
As i understood after deeply consuming these link with documintation i was not very well knowed about webpack and node eco-system as i should (In fact when i was learning about js i didnt even mention about it). The differens between commonjs and ESM is huge and some of modern package decide to use esm now. Thanks for the links i appreciate it.