question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Node 10 (using esm) error

See original GitHub issue

index.js

import { GraphQLNonNull, GraphQLList, GraphQLBoolean } from 'graphql'
import { GraphQLUpload } from 'apollo-upload-server'
import resolve from './resolver'

export default {
  type: GraphQLBoolean,
  args: {
    files: {
      type: new GraphQLList(new GraphQLNonNull(GraphQLUpload))
    }
  },
  resolve
}

result

(node:20404) UnhandledPromiseRejectionWarning: file:///Users/macbook/WebstormProjects/project/node_modules/apollo-upload-server/lib/types.mjs:1
import { GraphQLScalarType } from 'graphql'

SyntaxError: Missing export name 'GraphQLScalarType' in ES module: file:///Users/macbook/WebstormProjects/project/node_modules/graphql/index.js
    at file:///Users/macbook/WebstormProjects/project/node_modules/apollo-upload-server/lib/types.mjs:1
(node:20404) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mike-marcaccicommented, Jul 19, 2018

I’m going to guess this is a bug I noticed with babel 7 where destructuring imports is broken. To work around this, I believe we need to change our syntax to:

import * as graphql from 'graphql'
const { GraphQLScalarType } = graphql;
0reactions
jaydensericcommented, Jul 19, 2018

@qertis The issue is your graphql version (v0.10.1) needs to be at least v0.13.1. That is the first version to have proper ESM named exports, .mjs, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - How would you fix an 'ERR_REQUIRE_ESM' error?
4 Answers 4 · 1)Use fix esm https://www.npmjs.com/package/fix-esm module & import the module like this: const someModule = require("fix-esm"). · 2 ...
Read more >
Error when using ESM that works with ts-node #212 - GitHub
When I use import with ts-node, it works, but then when I run the same script with ts-node-dev, then I get this error...
Read more >
Using ECMAScript modules (ESM) with Node.js
Learn about using ES modules in Node.js today and get a closer look at how you can migrate your codebase to make use...
Read more >
What does it take to support Node.js ESM? – The Guild
js v10.x is dropped, everything should be fine and supporting ESM shouldn't be that hard. After working on migrating all The Guild libraries, ......
Read more >
Error ERR REQUIRE ESM | Must use import to load ES Module
How to use ES Modules in Node. · Top 5 Excel Functions for Finance People ( with end-to-end example) · Require vs Import...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found