You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装react-instagram-embed包后出现「Module not found: Error: Can't resolve 'querystring'」错误,如何解决?

Fix: Module not found: Can't resolve 'querystring' with react-instagram-embed

Hey there, I’ve run into this exact issue before—let’s break down how to fix it quickly.

The error pops up because webpack 5 no longer includes polyfills for Node.js core modules by default (webpack < 5 used to handle this automatically). The finnhub package (a dependency of react-instagram-embed) is trying to access the querystring module, which webpack 5 doesn’t provide out of the box anymore.

You’ve got two clear solutions depending on whether you need the querystring functionality or not:

Option 1: Add the polyfill (if you need querystring)

If your app or its dependencies rely on querystring to work properly, follow these steps:

  • First, install the polyfill package:
    npm install querystring-es3 --save
    # Or with yarn:
    yarn add querystring-es3
    
  • Then, update your webpack configuration file (usually webpack.config.js) to add the fallback for querystring:
    module.exports = {
      // ... your existing webpack config
      resolve: {
        fallback: {
          "querystring": require.resolve("querystring-es3")
        }
      }
    };
    

Option 2: Disable the module (if you don’t need querystring)

If you’re certain your app doesn’t depend on the querystring module, you can tell webpack to ignore it entirely:

  • Update your webpack config with this fallback setting:
    module.exports = {
      // ... your existing webpack config
      resolve: {
        fallback: {
          "querystring": false
        }
      }
    };
    

Note for Create React App users

If you’re using Create React App (which hides the webpack config by default), you’ll need a tool like craco or react-app-rewired to modify the config. For example, with craco:

  1. Install craco: npm install @craco/craco --save
  2. Create a craco.config.js file in your project root with the same resolve.fallback configuration shown above.
  3. Update your package.json scripts to use craco instead of react-scripts (e.g., replace "start": "react-scripts start" with "start": "craco start").

内容的提问来源于stack exchange,提问作者payal_harwani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 09:14:08