contra/graphql-helix

Error: Cannot find module `<path>\node_module\graphql-helix\dist\dist.js`

RoboZoom opened this issue · 3 comments

I'm currently using GraphQL-Helix in a developmental full stack project. After returning from the Front End to do some API work, my unchanged API is providing this error:

Error: Cannot find module '<path>\node_modules\graphql-helix\dist\dist.js'
    at createEsmNotFoundErr (internal/modules/cjs/loader.js:912:15)
    at finalizeEsmResolution (internal/modules/cjs/loader.js:905:15)
    at resolveExports (internal/modules/cjs/loader.js:437:14)
    at Function.Module._findPath (internal/modules/cjs/loader.js:477:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:872:27)
    at Function.Module._load (internal/modules/cjs/loader.js:730:27)
    at Module.require (internal/modules/cjs/loader.js:957:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.graphql-helix/dist (<path>\dist\apps\api\webpack:\<namespace>\external commonjs "graphql-helix\dist":1:1)
    at __webpack_require__ (<path>\dist\apps\api\webpack:\<namespace>\webpack\bootstrap:19:1)

On manual inspection, the dist.js file is not present.

I needed to go back 2 months to find a version of my software where the API compiled correctly. I tried reverting GraphQL-Helix to that version (1.7), however that did not fix the problem in the current build. I believe that this transition is related to my tooling (Nx) transitioning from Webpack 4 to Webpack 5.

My project is an Express app that is part of a larger Nx monorepo. I'm currently using GraphQL-Helix version 1.11, Nx version 13.4. The @nrwl/node plugin is using Webpack version 5.58.1

If anyone has any idea what could be going on, thoughts would be appreciated.

After further troubleshooting, I've created a minimally functional repository replicating this issue: https://github.com/RoboZoom/GraphQL-Helix-Sample

While not completely conclusive, I'm persuaded that the issue lies somewhere in the packaging of GraphQL-Helix and it's interaction with Webpack v5.

Hi @RoboZoom , are you loading Helix from the frontend code? it seems like webpack is trying to bundle it and fails?

@n1ru4l thoughts?

@dotansimha Thank you for looking into this! Short story long, I started tonight replicating the problem on a build without front end code. I was able to do so, then tried to replicate a functional implementation in an environment using Webpack v4. When this wouldn't build either, and I realized that Webpack was not the issue and returned to basics.

It appears as if the import directory I had been using (graphql-helix/dist) was no longer functioning. I changed my imports to graphql-helix and everything worked. My repo had been using this import structure for 6+ months (probably auto-populated by my IDE) - I don't know what changed so that this now led to an error state but not before, but now it functions appropriately.

Thank you all again for your time, and apologies for the confusion.