graphql-server
graphql-server copied to clipboard
Navigation errors?
I created a new project with
npm init svelte@next my-app
cd my-app
npm i
Then to add graphql
npx svelte-add graphql
npm i
everything seems to be working when I'm running npm run dev, but when I run npm run build, and then npm run preview to preview the production build, I'm getting the following error.
> The requested module 'graphql' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from 'graphql';
const {GraphQLSchema, GraphQLObjectType, GraphQLInt} = pkg;
file:///<path>/my-app/.svelte/output/server/app.js:8
import {GraphQLSchema, GraphQLObjectType, GraphQLInt} from "graphql";
^^^^^^^^^^
SyntaxError: The requested module 'graphql' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from 'graphql';
const {GraphQLSchema, GraphQLObjectType, GraphQLInt} = pkg;
at ModuleJob._instantiate (internal/modules/esm/module_job.js:97:21)
at async ModuleJob.run (internal/modules/esm/module_job.js:135:5)
at async Loader.import (internal/modules/esm/loader.js:178:24)
at async start (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/chunks/index6.js:275:14)
at async file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/cli.js:753:4
Does this still happen on Node 14.16.1 or 16.1.0?
I was using v14.4.0, so I tried updating to v14.16.1. After updating, the /graphql endpoint is working, but now the index page is broken somehow, now If I goto / page even in development I'm getting 500 and the following error in console.
Cannot read property 'split' of undefined
TypeError: Cannot read property 'split' of undefined
at parse_body (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:1333:60)
at respond (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:1454:11)
at fetch (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:703:30)
at load (index.svelte:13:30)
at load_node (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:790:30)
at respond$1 (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:1011:21)
at async render_page (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:1158:20)
at async render (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:1477:10)
at async respond (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:1450:10)
at async Immediate.<anonymous> (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/chunks/index.js:3304:23)
Unexpected token T in JSON at position 0
SyntaxError: Unexpected token T in JSON at position 0
at JSON.parse (<anonymous>)
at Proxy.<anonymous> (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:762:22)
at async load (index.svelte:22:33)
at async load_node (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:790:12)
at async respond$1 (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:1011:15)
at async render_page (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:1158:20)
at async render (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:1477:10)
at async respond (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/ssr.js:1450:10)
at async Immediate.<anonymous> (file:///home/anonymous/Documents/Sveltekit_Projects/e-commerce/node_modules/@sveltejs/kit/dist/chunks/index.js:3304:23)
Same is happening with v16.1.0.