Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module 'core-js/modules/es7.object.entries' #1542

Closed
wawhal opened this issue Aug 16, 2018 · 14 comments
Closed

Error: Cannot find module 'core-js/modules/es7.object.entries' #1542

wawhal opened this issue Aug 16, 2018 · 14 comments
Labels

Comments

@wawhal
Copy link

wawhal commented Aug 16, 2018

I am trying to serve an executable schema. I get the following error while using version 2.0.2. Works totally fine with version 2.0.0.

Error: Cannot find module 'core-js/modules/es7.object.entries'
    at Object.<anonymous> (/home/wawhal/oss/schema-stitching-examples/multiple-remote-graphql-apis/node_modules/apollo-upload-server/lib/middleware.js:14:1)

Here is the code:

import {
  makeRemoteExecutableSchema,
  introspectSchema,
  mergeSchemas
} from 'graphql-tools';
import { HttpLink } from 'apollo-link-http';
import { ApolloServer } from 'apollo-server';
import fetch from 'node-fetch';

// secret keys
const GITHUB_TOKEN = process.env.GITHUB_TOKEN || 'github-token';
const X_HASURA_ACCESS_KEY = process.env.X_HASURA_ACCESS_KEY || '<key>';

// graphql API metadata
const graphqlApis = [
  {
    uri: 'https://api.github.com/graphql',
    headers: { 'Authorization': `Bearer ${GITHUB_TOKEN}` }
  },
  {
    uri: 'https://api1.com/graphql',
    headers: { 'x-hasura-access-key': X_HASURA_ACCESS_KEY }
  }
];

// create executable schemas from remote GraphQL APIs
const createRemoteExecutableSchemas = async () => {
  let schemas = [];
  for (const api of graphqlApis) {
    const link = new HttpLink({
      uri: api.uri,
      headers: api.headers,
      fetch
    });
    const remoteSchema = await introspectSchema(link);
    const remoteExecutableSchema = makeRemoteExecutableSchema({
      schema: remoteSchema,
      link
    });
    schemas.push(remoteExecutableSchema);
  }
  return schemas;
};

const createNewSchema = async () => {
  const schemas = await createRemoteExecutableSchemas();
  console.log(schemas);
  return mergeSchemas({
    schemas
  });
};

const runServer = async () => {
  console.log('here');
  // Get newly merged schema
  const schema = await createNewSchema();
  // start server with the new schema
  const server = new ApolloServer({
    schema
  });
  server.listen().then(({url}) => {
    console.log(`Running at ${url}`);
  });
};

try {
  console.log('here');
  runServer();
} catch (err) {
  console.error(err);
}

/label bug

@ghost ghost added the 🪲 bug label Aug 16, 2018
@nicholasxuu
Copy link

official getting-started example shows the same error.

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

@andyrichardson
Copy link

I am having the same problem using apollo-server-express.

The issue seems to be caused by the peer dependency apollo-upload-server (see related issue here).

@fungiboletus
Copy link

A temporary workaround : npm install core-js

abernix added a commit that referenced this issue Aug 20, 2018
…ependency.

As reported in #1542,
the `apollo-upload-server` package (v5.0.0, which `apollo-server` relies on)
is no longer able to provide a `core-js` package because of change that was
outside of its control in a Babel release.

The problem is resolved in newer versions of `apollo-upload-server`,
however, regrettably, the newer versions of that package (notably, v6 and
v7) drop support for Node.js 6 — one of two versions of Node.js that are
currently under the terms of the Node.js Foundation's Long-Term-Support
(LTS) agreements.

Since Apollo Server aims to support versions of Node.js which are under LTS
(and will drop support for Node.js 6 in April 2019, per Node.js' schedule)
the current, immediate solution is to fork the `apollo-upload-server`
package as `@apollographql/apollo-upload-server`.

With the inclusion of
https://github.com/apollographql/apollo-upload-server/pull/1, we are able to
keep supporting Node.js 6.  Without this change, every new installation
of `apollo-server`, which doesn't have a `package-lock.json` preventing
transitive dependency updates - specifically, the updates to
`@babel/runtime` versions newer than `-beta.56` - is broken.
evans pushed a commit that referenced this issue Aug 20, 2018
…ependency. (#1556)

* Switch to a fork of `apollo-upload-server` to fix missing `core-js` dependency.

As reported in #1542,
the `apollo-upload-server` package (v5.0.0, which `apollo-server` relies on)
is no longer able to provide a `core-js` package because of change that was
outside of its control in a Babel release.

The problem is resolved in newer versions of `apollo-upload-server`,
however, regrettably, the newer versions of that package (notably, v6 and
v7) drop support for Node.js 6 — one of two versions of Node.js that are
currently under the terms of the Node.js Foundation's Long-Term-Support
(LTS) agreements.

Since Apollo Server aims to support versions of Node.js which are under LTS
(and will drop support for Node.js 6 in April 2019, per Node.js' schedule)
the current, immediate solution is to fork the `apollo-upload-server`
package as `@apollographql/apollo-upload-server`.

With the inclusion of
https://github.com/apollographql/apollo-upload-server/pull/1, we are able to
keep supporting Node.js 6.  Without this change, every new installation
of `apollo-server`, which doesn't have a `package-lock.json` preventing
transitive dependency updates - specifically, the updates to
`@babel/runtime` versions newer than `-beta.56` - is broken.

* [squash] Update to `@apollographql/apollo-upload-server@5.0.2`.

* [squash] Update to `@apollographql/apollo-upload-server@5.0.3`.
@abernix
Copy link
Member

abernix commented Aug 21, 2018

This is now fixed in apollo-server@2.0.5 (and the apollo-server-{integration} packages, like apollo-server-express) thanks to 8347511 in #1556.

Therefore, if you've previously installed core-js as a direct dependency of your application to overcome this problem (as suggested in #1542 (comment) above), you can now npm install apollo-server@2.0.5 (or the appropriate integration package!) and npm uninstall core-js.

Thanks for reporting this originally!

@abernix abernix closed this as completed Aug 21, 2018
@abenhamdine
Copy link

abenhamdine commented Aug 21, 2018

hmm npm install apollo-server-express@2.0.5 fails because version unfound, it doesn't look published yet.
I assume apollo-server-express@2.0.4 which has been published with apollo-server@2.0.5 contains the fix.

@abernix
Copy link
Member

abernix commented Aug 21, 2018

@abenhamdine Sorry, you're right, I should have just said "it's fixed in latest" since the integration packages have independent versioning now to avoid bumping all integrations versions when only one of the underlying integration frameworks has changed (e.g. if only express's API changed, we'd have had to confusingly bump apollo-server-hapis version too). Thanks for pointing this out!

@artboard-studio
Copy link

This is still not fixed for apollo-server-koa@rc which seems to be left behind from other apollo-server integrations!

@abernix
Copy link
Member

abernix commented Aug 27, 2018

@Human-a The official release of apollo-server and apollo-server-koa 2.x has come out and neither are still in the release-candidate phase. However, the rc tag still points to the last release candidate version of apollo-server-koa. I believe if you'd like to get this fix, you'd need to move to the latest tag. The rc tag will likely remain pointed to the last 2.x RC until the next series of release candidate testing begins — most likely to occur whenever apollo-server-* 2.1.x packages mature to an RC state.

That is to say, can you try with apollo-server-koa@2.0.4 – as of this writing, the latest/most recent version?

@artboard-studio
Copy link

Awesome! thanks :)

@zainulabidin302
Copy link

After upgrading to 2.3.3, I got the same error again. Downgrading to 2.0.4 fixed it.

@marcel-devdude
Copy link

Same here 😞

@eliotis
Copy link

eliotis commented Feb 2, 2019

Same here but with following error:
"Error: Cannot find module 'core-js/proposals/array-flat-and-flat-map"
Fixed by downgrading to 2.0.7

@giovangonzalez
Copy link

I'm using apollo-server-express 2.2.6 and yarn install, any idea about how to solve this? I have another project with same base code and package version and it is working!

@apollographql apollographql locked as resolved and limited conversation to collaborators Jul 28, 2019
@abernix
Copy link
Member

abernix commented Jul 28, 2019

@giovangonzalez Please update to a newer version of Apollo Server and see if the problem is still occurring. If it is, please open a new issue with a runnable reproduction, per the instructions when opening a new issue. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants