alan345/TER

Error when starting Prisma - STEP 4

Closed this issue · 4 comments

On step 4 when tried to start Prisma I am getting an error.

/Users/dccecili/Projects/workplace/dccecili/PersonalProjects/naperg/server/index.js:10
    ...req,
    ^^^

SyntaxError: Unexpected token ...
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.runMain (module.js:611:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:160:9)

npm ERR! Darwin 16.7.0
npm ERR! argv "/usr/local/Cellar/node@6/6.14.4/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.14.4
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! my-app@ start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app@ start script 'node index.js'.```

UPDATED answer
Solution is here: howtographql/howtographql#652
You are most probably running an old version of nodejs. Make sure you have at least version 5.12.

PREVIOUS answer
hi, it looks like you the spread operator is not working for you.
This server page is from prisma doc:
https://www.prisma.io/docs/tutorials/build-graphql-servers/development/build-a-graphql-server-from-scratch-nahgaghei6#implementing-resolvers-with-prisma-bindings

const server = new GraphQLServer({
  typeDefs: './src/schema.graphql',
  resolvers,
  context: req => ({
    ...req,
    db: new Prisma({
      typeDefs: 'src/generated/prisma.graphql', // the generated Prisma DB schema
      endpoint: '__PRISMA_ENDPOINT__',          // the endpoint of the Prisma DB service
      secret: 'mysecret123',                    // specified in database/prisma.yml
      debug: true,                              // log all GraphQL queries & mutations
    }),
  }),
})

server.start(() => console.log('Server is running on http://localhost:4000'))

try with another example for prisma and see if it works. https://www.prisma.io/docs/get-started/01-setting-up-prisma-new-database-a002/
Let me know!

I got the docker and prisma up and running just fine.

But when I try running npm start on the server for Prisma: Graphql and mySql I got that error.

Not sure what to do...

Ok it worked.

I have updated to the latest node and npm version.

Current version:

node: v8.12.0
npm: v6.4.1

Great to hear!