FG
๐Ÿ”Œ APIs & SDKs

Compile error with webpack 4

Freshabout 20 hours ago
Mar 14, 20260 views
Confidence Score95%
95%

Problem

Hi, After updating to webpack 4, compiling graphiql doesn't work because of the graphql-js dependency. I get a bunch of those errors: [code block] (and a million more) Seems like forcing the downgrade to a graphql-js version that doesn't have .mjs files fixes the issue.

Error Output

ERROR in ./node_modules/graphql/index.mjs

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix โ€“ Awaiting Verification

Resolve Webpack 4 Compile Error by Downgrading graphql-js

Medium Risk

The compile errors occur due to the introduction of .mjs files in the graphql-js dependency, which are not compatible with the current Webpack 4 configuration. Webpack 4 has issues handling ES modules (.mjs) without proper configuration, leading to errors during the build process.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Check Current graphql-js Version

    Verify the currently installed version of graphql-js in your project to confirm if it is causing the issue.

    bash
    npm list graphql
  2. 2

    Uninstall Current graphql-js Version

    Remove the current version of graphql-js that is causing the compile errors.

    bash
    npm uninstall graphql
  3. 3

    Install Compatible graphql-js Version

    Install a previous version of graphql-js that does not include .mjs files, such as version 14.0.0.

    bash
    npm install graphql@14.0.0
  4. 4

    Update Webpack Configuration (if necessary)

    If you still encounter issues, consider updating your Webpack configuration to handle .mjs files by adding the appropriate rules for module resolution.

    javascript
    module: { rules: [{ test: /\.m?js$/, exclude: /node_modules/, use: { loader: 'babel-loader' } }] }
  5. 5

    Rebuild the Project

    After making the changes, rebuild your project to ensure that the new configuration and dependency are applied.

    bash
    npm run build

Validation

To confirm the fix worked, run the build command again and check for any compile errors. If the build completes successfully without errors related to graphql-js, the issue is resolved.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

graphqlapischema