You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The extensions should work and load the local schema.
Actual outcome:
Cannot load schema.
[ERROR] A config file failed to load with options: {"configPath":"/***/***/Desktop/test","requireConfig":true}.
The error was: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /***/***/Desktop/test/apollo.config.js
require() of ES modules is not supported.
require() of /***/***/Desktop/test/apollo.config.js from /***/***/.vscode/extensions/apollographql.vscode-apollo-1.19.3/node_modules/import-fresh/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename apollo.config.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /***/***/Desktop/test/package.json.
at Object.loadConfig (/***/***/.vscode/extensions/apollographql.vscode-apollo-1.19.3/node_modules/apollo-language-server/lib/config/loadConfig.js:42:34)
at async GraphQLWorkspace.reloadProjectForConfig (/***/***/.vscode/extensions/apollographql.vscode-apollo-1.19.3/node_modules/apollo-language-server/lib/workspace.js:107:22)
at /***/***/.vscode/extensions/apollographql.vscode-apollo-1.19.3/src/extension.ts:77:17
at handleNotification (/***/***/.vscode/extensions/apollographql.vscode-apollo-1.19.3/node_modules/vscode-jsonrpc/lib/main.js:489:43)
at processMessageQueue (/***/***/.vscode/extensions/apollographql.vscode-apollo-1.19.3/node_modules/vscode-jsonrpc/lib/main.js:260:17)
at Immediate._onImmediate (/***/***/.vscode/extensions/apollographql.vscode-apollo-1.19.3/node_modules/vscode-jsonrpc/lib/main.js:247:13)
This is because in the package.json there is "type": "module" set. Node then treats files as modules and not commonjs. This means that module.exports does not work.
How to reproduce the issue:
Create a package.json. (See below)
Add a config file apollo.config.js with an endpoint (See below)
Intended outcome:
The extensions should work and load the local schema.
Actual outcome:
Cannot load schema.
This is because in the
package.json
there is"type": "module"
set. Node then treats files as modules and not commonjs. This means thatmodule.exports
does not work.How to reproduce the issue:
package.json
. (See below)apollo.config.js
with an endpoint (See below)Versions
v1.19.3
Additional Information
apollo-tooling/packages/apollo-language-server/src/config/loadConfig.ts
Lines 21 to 25 in be117f3
I'm not sure but a possible solution could be also accepting
apollo.config.cjs
as a supported config file option. Should be testedThe text was updated successfully, but these errors were encountered: