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.

Reports GraphQL syntax errors in cjs & mjs files

See original GitHub issue

Actual Behavior

when writing cjs or mjs, vscode-graphql reports gql syntax errors on the first keyword.

Expected Behavior

no error is shown and vscode-graphql treats it like other js files insteadof trying to parse it as gql

Steps to Reproduce the Problem Or Description

create an cjs or mjs file and add any valid js code, e.g. in a cjs file:

module.exports = {};


  • GraphQL for VSCode Extension Version: 0.3.15
  • VS Code:
  • Version: 1.53.2 (system setup)
  • Commit: 622cb03f7e070a9670c94bae1a45d78d7181fbd4
  • Date: 2021-02-11T11:48:04.245Z
  • Electron: 11.2.1
  • Chrome: 87.0.4280.141
  • Node.js: 12.18.3
  • V8:
  • OS: Windows_NT x64 10.0.19042

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:14
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

codekitchencommented, Aug 18, 2021

I’m still seeing this as well. It causes a phantom error in vscode Problems pane that can never be fixed.

macmillencommented, Nov 26, 2021

confirmed. ✔️ thanks a lot for fixing it @acao ! 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling operation errors - Apollo GraphQL Docs
These are errors related to the server-side execution of a GraphQL operation. They include: ... If a syntax error or validation error occurs,...
Read more >
Instead change the require of index.js, to a dynamic import ...
In my case, I was getting the error after installing the latest version of crypto-random-string package. To know which package is causing ...
Read more >
import fetch from "node-fetch"; ^^^^^^ syntaxerror: cannot ... -
This will ensure that all .js and .mjs files are interpreted as ES modules. ... Error "SyntaxError: Cannot use import statement outside a...
Read more >
Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
Use ESM - use import foo from 'foo' , instead of const foo = require('foo') and add the following line to your package.json...
Read more >
Configuring Jest
Jest's configuration can be defined in the package.json file of ... file or through the --config <path/to/file.js|ts|cjs|mjs|json> option.
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 Post

No results found

github_iconTop Related Hashnode Post

No results found