0

I'm learning how to create graphql servers and i'm trying to create an executable schema with graphql-tools. However, when I run the example code on my server file, it returns a syntax error. Do you know what could be happening? I'm running on Windows 10

The error stack is as follows:

C:\Users\tranv\Documents\frontendMentor\link-sharing-app\node_modules\@graphql-tools\utils\cjs\helpers.js:46
        name = a.alias?.value;
                       ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:1053:16)
    at Module._compile (internal/modules/cjs/loader.js:1101:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\tranv\Documents\frontendMentor\link-sharing-app\node_modules\@graphql-tools\utils\cjs\index.js:5:22)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)

My code is just a bare express server with a makeExcutableSchema example:

const express = require('express');
const port = 5000;
const makeExecutableSchema = require('@graphql-tools/schema');

const executableSchema = makeExecutableSchema({
  typeDefs: schema,
  resolvers: {
    Query: {
      hello: () => 'Hello, world!',
    },
  },
});

const app = express();
app.listen(port, console.log(`Server running on port ${port}`));

Did I install something incorrectly?

I'm not sure why the syntax error is appearing. I also get some similar syntax error when I try out yoga graphql server (some unexpected token in the node_moudules file). Maybe it has the same issuses?

  • What is in `schema`? – Michel Floyd Aug 04 '23 at 15:53
  • @MichelFloyd I was copying around some commented-out mess since I was testing multiple things, but the schema was something like const schema = `type Query {hello: String}`;. Anyway, I tried running the code on my Linux computer and everything works now, so it was indeed Windows' fault – Vinh Tran Aug 05 '23 at 12:59

0 Answers0