parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.84k stars 4.77k forks source link

Error: Cannot find module 'react' after upgrading from 4.10.0 to 4.10.3 #7578

Closed stage88 closed 2 years ago

stage88 commented 3 years ago

New Issue Checklist

Issue Description

I am getting the following error on start up after upgrading from 4.10.0 to 4.10.3

Error: Cannot find module 'react'
Require stack:
- /var/www/app/current/node_modules/@apollo/client/react/context/context.cjs.js
- /var/www/app/current/node_modules/@apollo/client/react/react.cjs.js
- /var/www/app/current/node_modules/@apollo/client/main.cjs.js
- /var/www/app/current/node_modules/@apollo/client/utilities/utilities.cjs.js
- /var/www/app/current/node_modules/@apollo/client/link/core/core.cjs.js
- /var/www/app/current/node_modules/@apollo/client/core/core.cjs.js
- /var/www/app/current/node_modules/apollo-upload-client/public/createUploadLink.js
- /var/www/app/current/node_modules/apollo-upload-client/public/index.js
- /var/www/app/current/node_modules/@graphql-tools/links/index.cjs.js
- /var/www/app/current/node_modules/parse-server/lib/GraphQL/loaders/defaultGraphQLTypes.js
- /var/www/app/current/node_modules/parse-server/lib/GraphQL/ParseGraphQLSchema.js
- /var/www/app/current/node_modules/parse-server/lib/GraphQL/ParseGraphQLServer.js
- /var/www/app/current/node_modules/parse-server/lib/ParseServer.js
- /var/www/app/current/node_modules/parse-server/lib/index.js
- /var/www/app/current/app.js
- /var/www/app/current/bin/server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Module.Hook._require.Module.require (/var/www/app/current/node_modules/require-in-the-middle/index.js:61:29)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/var/www/app/current/node_modules/@apollo/client/react/context/context.cjs.js:6:13)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at Module.Hook._require.Module.require (/var/www/app/current/node_modules/require-in-the-middle/index.js:80:39) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/var/www/app/current/node_modules/@apollo/client/react/context/context.cjs.js',
    '/var/www/app/current/node_modules/@apollo/client/react/react.cjs.js',
    '/var/www/app/current/node_modules/@apollo/client/main.cjs.js',
    '/var/www/app/current/node_modules/@apollo/client/utilities/utilities.cjs.js',
    '/var/www/app/current/node_modules/@apollo/client/link/core/core.cjs.js',
    '/var/www/app/current/node_modules/@apollo/client/core/core.cjs.js',
    '/var/www/app/current/node_modules/apollo-upload-client/public/createUploadLink.js',
    '/var/www/app/current/node_modules/apollo-upload-client/public/index.js',
    '/var/www/app/current/node_modules/@graphql-tools/links/index.cjs.js',

Steps to reproduce

Upgrade from 4.10.0 to 4.10.3

Actual Outcome

The server does not start

Expected Outcome

Expected server to start

Environment

Server

Database

Client

Logs

parse-github-assistant[bot] commented 3 years ago

Thanks for opening this issue!

junya100 commented 3 years ago

Same here. Any update?

polyglots-kikuchi commented 3 years ago

Same on my environment (ver. 4.10.2).

I've confirmed using ver. 4.3.0 is fine but ver.4.4.0 or later are not good. The error started about 9 hours ago. New instances on our auto scaling environment wasn't able to start the app. So I guess any libraries around apollo-client were updated in the last 12 hours and affect to our environment.

junya100 commented 3 years ago

It seems to be caused from apollo-client version 3.4.12. https://github.com/apollographql/apollo-client/issues/8809

charlesteel commented 3 years ago

Getting this issue as well. Any updates on a fix?

charlesteel commented 3 years ago

Added react to my package list through npm install and that seems to have fixed it

Taylorsuk commented 3 years ago

I did have the exact error above. I removed node modules and package.lock before running a clean npm install. Then my error changed to

internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'graphql'
Require stack:
- /parse/node_modules/graphql-upload/public/GraphQLUpload.js
- /parse/node_modules/graphql-upload/public/index.js
- /parse/node_modules/parse-server/lib/GraphQL/ParseGraphQLServer.js
- /parse/node_modules/parse-server/lib/ParseServer.js
- /parse/node_modules/parse-server/lib/index.js
- /parse/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/parse/node_modules/graphql-upload/public/GraphQLUpload.js:3:45)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/parse/node_modules/graphql-upload/public/GraphQLUpload.js',
    '/parse/node_modules/graphql-upload/public/index.js',
    '/parse/node_modules/parse-server/lib/GraphQL/ParseGraphQLServer.js',
    '/parse/node_modules/parse-server/lib/ParseServer.js',
    '/parse/node_modules/parse-server/lib/index.js',
    '/parse/index.js'
  ]
}

So I npm installed graphql and the server spins up again now, feels like a hack, hopefully a proper fix is deployed soon.

stage88 commented 3 years ago

Not sure if its too much to ask, however I would have loved to have the option of not loading all the GraphQL deps since i dont use GraphQL with Parse Server. The approach that is currently used for some of the other adapters works better imo, so those that want GraphQL with Parse can for example npm install @parse/graphql-adapter and configure via options.

Thats a sideway conversation, apologies...

mtrezza commented 3 years ago

This doesn't seem to be an issue with Parse Server, but with the apollo dependency (https://github.com/apollographql/apollo-client/issues/8809). It seems strange however that Parse Server stops working despite a package-lock file, which should fixate the dependencies. We'll track https://github.com/apollographql/apollo-client/issues/8809 to see whether this will be fixed upstream, or whether we have to do something about it.

@stage88 I think your suggestion makes sense. Unfortunately we keep experiencing issues in relation to GraphQL dependencies in parse server and parse dashboard. And for deployments not using GraphQL there should be no reason why they get security warnings or other issues due to GraphQL dependencies.

mtrezza commented 2 years ago

The issue may have been fixed in @apollo/client@3.4.13. We just need to check which of our dependencies requires that and whether they have bumped as well. Or maybe we can just regenerate package-lock and that solved the issue.

stage88 commented 2 years ago

@mtrezza Just tried doing an npm install with "parse-server": "4.10.3", everything starts up fine. It looks like the issue has been fixed downstream.

mtrezza commented 2 years ago

Great, thanks for reporting back! I'm closing as this issue seems to be resolved.