Search code examples
node.jsreactjsgraphqlphoenix-frameworkabsinthe

Fail to import Phoenix npm package in overmind graphql


I re-installed all node modules using npm install run into the error:
Cannot find module 'phoenix' from 'node_modules/@absinthe/socket/compat/cjs/index.js'

It fails first in the @absinthe code:
require('phoenix'); in @absinthe/socket/compat/cjs/index.js

but overmind-graphql relies on phoenix as well and the IDE shows a broken import:
import { Socket as PhoenixSocket } from 'phoenix'; in this line in overmind-graphql

The relevant package versions I have installed for this:

"overmind": "^28.0.1",
"overmind-graphql": "^8.0.1",
"overmind-react": "^29.0.1",
"phoenix": "^1.6.0",
"@absinthe/socket": "^0.2.1",
"graphql": "^15.5.1",
"graphql-react": "^15.0.0",
"graphql-tag": "^2.12.4",
"react": "^17.0.1"

I tried:

  • "phoenix" and "@absinthe/socket" were dependencies before, so I manually installed them
  • remove all node_modules and re-install all packages
  • remove package-lock.json, node_modules and re-install all packages
  • removing the import of overmind in my React component: no errors because it doesn't reach the failing phoenix import
  • run next build and next start instead of the always reloading next dev

Solution

  • The fix is using the specific version of the phoenix package that overmind-graphql relies on:
    "phoenix": "1.4.13"

    Seems like the re-install didn't help, but just confused me more.