next.jspackage.jsonapollo-server

Running apollo Server for Next.js app giving error


As I am using graphql and need to run local server (Apollo server), I am struggling to setup for the Next.js project. I am totally a beginner . In order to run the apollo server, it says to create server.ts , which I have created at the root of the project folder as below: App - src - server - public

when I run 'npm start' , it gives error pm ERR! Missing script: "start" npm ERR! npm ERR! Did you mean one of these? npm ERR! npm star # Mark your favorite packages npm ERR! npm stars # View packages marked as favorites

Is there anything I need to change in tscofig?


Solution

  • You need to define the start command in the scripts section of your package.json file.

    Ex:

    "scripts": {
      "compile": "tsc",
      "start": "npm run compile && node ./dist/index.js",
    },