This seems related to another post, but I wanted to document that although the tutorial specifies:
You’ll need to have at least Node version 14.18 and npm version 6.14.
Version 18.9.0 of NodeJS seems incompatible. When I tried npm start
on the locations subgraph (Part III), I got the following error:
TypeError: types.flatMap is not a function
at printSchema (odyssey-voyage-I/subgraph-locations/node_modules/@apollo/federation-internals/dist/print.js:56:68)
at Schema.toAST (odyssey-voyage-I/subgraph-locations/node_modules/@apollo/federation-internals/dist/definitions.js:932:70)
at Schema.validate (odyssey-voyage-I/subgraph-locations/node_modules/@apollo/federation-internals/dist/definitions.js:1160:55)
at Subgraph.validate (odyssey-voyage-I/subgraph-locations/node_modules/@apollo/federation-internals/dist/federation.js:941:25)
at buildSubgraph (odyssey-voyage-I/subgraph-locations/node_modules/@apollo/federation-internals/dist/federation.js:653:21)
at buildSubgraphSchema (odyssey-voyage-I/subgraph-locations/node_modules/@apollo/subgraph/dist/buildSubgraphSchema.js:27:63)
at Object.<anonymous> (odyssey-voyage-I/subgraph-locations/index.js:10:11)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
[nodemon] app crashed - waiting for file changes before starting...
Downgrading to v16 (as recommended in the other thread), resolved the issue.