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

Created on 2 Feb 2019  路  16Comments  路  Source: apollographql/apollo-server

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"
  }
}

Most helpful comment

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

All 16 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 was experiencing the exact same problem here. I temporarily fixed it by setting "core-js": "3.0.0-beta.11" on package.json.

thanks for that! my workaround was to downgrade my apollo-server version. 馃槵

"dependencies": {
"apollo-server-express": "^2.3.3",
"arangojs": "^5.8.0",
"babel-loader": "^8.0.5",
"babel-polyfill": "^6.26.0",
"body-parser": "^1.18.3",
"core-js": "3.0.0-beta.11",
"express": "^4.16.4",
"firebase-admin": "^6.5.0",
"graphql": "^14.0.2",
"graphql-tools": "^4.0.3",
"request": "^2.88.0"
},

Not sure why the workaround is not working for me.
I am on mac.

I'm so relieved I'm not the only one having this issue.

I'm not sure if this helps but I'm on a Mac using express and apollo-server-express/apollo-server throws the same error OP has.

finally copied core-js "core-js": "3.0.0-beta.11" to
cp -rf node_modules/core-js /usr/local/lib/node_modules/apollo/node_modules/
phew that's not a good solution but it works for me.

The last night I spent some hours investigating this and I was able to solve by installing this version [email protected] and [email protected].

I have had apollo-server-express (2.3.1) deployed for months on heroku running against express 4.16.4. As of this morning I cannot restart the server successfully because of this error.

I have tried all of the workaround suggested above. Nothing has worked.

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.

Experiencing same issue - not able to redeploy my dockerised production app - using node / debian stretch base container. I have tried workaround changing "apollo-server-express": "^2.3.3" but to no avail.

I also had the same problem by just setting up a simple server like in the docs with no extra code

For hour a solution is installing the "core-js": "3.0.0-beta.3" in application, but it is not recommended.

It may be any version between 3 and 11, issue is known since 12

I've installed [email protected] 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.

Thanks @shalkam! This wa worked just fine!

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!

Was this page helpful?
0 / 5 - 0 ratings