简体   繁体   中英

Apollo-server tutorial from GraphQL website produce error

I can't get this tutorial to work (running on Ubuntu v19.04):

https://www.apollographql.com/docs/apollo-server/getting-started/

My code is literally copy+pasted from the tutorial - I have installed all dependencies, and I keep getting the following error when running node index.js :

internal/modules/cjs/loader.js:628
  throw e;
  ^

Error: No valid exports main found for '{project-path}/node_modules/uuid'
    at resolveExportsTarget (internal/modules/cjs/loader.js:625:9)
    at applyExports (internal/modules/cjs/loader.js:502:14)
    at resolveExports (internal/modules/cjs/loader.js:551:12)
    at Function.Module._findPath (internal/modules/cjs/loader.js:657:22)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:960:27)
    at Function.Module._load (internal/modules/cjs/loader.js:855:27)
    at Module.require (internal/modules/cjs/loader.js:1033:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> ({project-path}/project-myra/node_modules/apollo-engine-reporting/dist/agent.js:26:16)
    at Module._compile (internal/modules/cjs/loader.js:1144:30) {
  code: 'MODULE_NOT_FOUND'

This is literally so frustrating, because the only place to get any help with apollo-server is from a Spectrum chat that keeps disconnecting, and doesn't even allow me to create any posts...

Why is this library the official supported and recommended library for GraphQL? And how come I seem to be the only person in the world having this issue, I can't find anyone else asking about this...

It seems it's a problem with the current Apollo Server version.

Try downgrading to 2.6.3, this worked for me. Haven't tried with any other version though.

npm install apollo-server@2.6.3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM