Compile error with webpack 4
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
Resolve Webpack 4 Compile Error by Downgrading graphql-js
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
Check Current graphql-js Version
Verify the currently installed version of graphql-js in your project to confirm if it is causing the issue.
bashnpm list graphql - 2
Uninstall Current graphql-js Version
Remove the current version of graphql-js that is causing the compile errors.
bashnpm uninstall graphql - 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.
bashnpm install graphql@14.0.0 - 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.
javascriptmodule: { rules: [{ test: /\.m?js$/, exclude: /node_modules/, use: { loader: 'babel-loader' } }] } - 5
Rebuild the Project
After making the changes, rebuild your project to ensure that the new configuration and dependency are applied.
bashnpm 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
Alex Chen
2450 rep