apollo-server: Fresh install fail on Mac: Cannot find module 'core-js/proposals/array-flat-and-flat-map'

A fresh install fails as follows after including const { ApolloServer, gql } = require('apollo-server');:

nodemon server.js
[nodemon] 1.18.9
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'core-js/proposals/array-flat-and-flat-map'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/Users/ulucaydin/repos/myproject/backend/node_modules/apollo-env/lib/polyfills/array.js:3:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
[nodemon] app crashed - waiting for file changes before starting...

Here is my package.json:

{
  "name": "backend",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@babel/polyfill": "^7.2.5",
    "babel": "^6.23.0",
    "core-js": "^2.6.3",
    "mongodb": "^3.1.13"
  },
  "devDependencies": {
    "apollo-server": "^2.3.3",
    "apollo-server-express": "^2.3.3",
    "express": "^4.16.4",
    "graphql": "^14.1.1",
    "install": "^0.12.2",
    "mongoose": "^5.4.9",
    "node-zillow": "^2.0.0",
    "nodemon": "^1.18.9",
    "npm": "^6.7.0"
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 18
  • Comments: 16 (1 by maintainers)

Most upvoted comments

I was experiencing the exact same problem here. I temporarily fixed it by setting "core-js": "3.0.0-beta.11" on package.json.

I’ve installed core-js@3.0.0-beta.11 still didn’t work for me. I had to added this to package.json to force this version to be used

  "resolutions": {
    "core-js": "3.0.0-beta.11"
  }

And it worked just fine.

It’s a yarn feature https://yarnpkg.com/lang/en/docs/selective-version-resolutions/ , I don’t know if it would work with npm.

Thank you to all those that reported this and supplied the appropriate work-arounds. This should have been fixed by apollo-tooling’s https://github.com/apollographql/apollo-tooling/pull/961 and I’m unable to reproduce the problem this morning.

There were no changes to apollo-server necessary to fix it.

If anyone is still experiencing this problem, please do report back!

Thanks @shalkam! This wa worked just fine!

I’m hitting this as well inasmuch as a previously working installation is now no longer working after a new npm install. I’m guessing that there’s an optimistic dependency in the chain that’s been upgraded that’s missing a reference to this module as its dependency. <== In case anybody is investigating this.

BTW - for me this is happening on Ubuntu 14.x and 18.x so it’s not just related to Macs.