ECMAScript module loading error
See original GitHub issueThank you for your great package. I have one question:
When using the program with ESM (.mjs import) I get an error with the current version of Node (9.4.0).
(node:4290) ExperimentalWarning: The ESM module loader is experimental.
file:///Users/.../node_modules/apollo-upload-server/lib/types.mjs:1
import { GraphQLScalarType } from 'graphql'
^^^^^^^^^^^^^^^^^
SyntaxError: The requested module does not provide an export named 'GraphQLScalarType'
at ModuleJob._instantiate (internal/loader/ModuleJob.js:86:19)
at <anonymous>
error Command failed with exit code 1.
The problem should be resolved by changing the following lines in types.mjs
:
import graphql from 'graphql'
const { GraphQLScalarType } = graphql
I think GraphQL exports currently only with CJS and not yet with ESM and therefore there is only the “default export”. Since you are running this program with Babel, you will not get an error. I use the package directly with Node.
https://nodejs.org/api/esm.html#esm_interop_with_existing_modules
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
ES6 module loading: More complicated than you think
In order to autodetect modules in JavaScript programs, you would first have to parse the entire file. Modules need not use import ,...
Read more >Error loading javascript .js files via ES6 module import from ...
Steps to reproduce the problem: 1. Create any html page that tries to use ECMAScript 2015 import to load javascript .js files from...
Read more >Error while loading config - You appear to be using a native ...
I needed this configuration at the root of my directory babel.config.cjs. cjs is what is applicable for Nodejs when using "type"="module".
Read more >JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax.
Read more >How to Bypass ES Modules Errors in Next.js with Dynamic ...
In this article, I'll walk you through an error you may get when you are building JavaScript apps with Next.js, and how to...
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
Now, it works - thanks 👍
Ok, maybe you can use a temporary solution with a mix of default and variable import like this one:
import myDefault, * as myModule from "my-module";
Not sure if it works for both, vanilla Node and Babel.And then you can add a conditional assignment like that:
const graphql = myDefault || myModule