react-share util.inherits 不是 webpack 2 的功能 [英] react-share util.inherits is not a function webpack 2

查看:30
本文介绍了react-share util.inherits 不是 webpack 2 的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在我的应用程序中包含 react-share 时,我遇到了下一个错误,所有编译都正常,如果我转到另一个没有加载此库的路由可以正常工作,但是当我包含它时会崩溃.

i have the next error when i try to include react-share in my app, all compile fine and if i go to another routes where no is loading this library works fine, but when i include it crash.

TypeError: util.inherits is not a function

我正在使用带有 webpack 2 的 webpack 开发服务器.我被嘲笑下一个模块

i am using webpack dev server with webpack 2. i am mocked the next modules

注意:我试图模拟 utils,因为 util 未在非节点环境中定义.

note: i tried to mock utils so because util is not defined in not node env.

node: {
    fs: "empty",
    child_process: "empty",
  },

推荐答案

我遇到了同样的问题,最终发现问题是我有一个文件夹名称 'util' 并且 webpack 以某种方式将它与函数 util.inhirits 混合.我更改了文件夹的名称,现在可以了.

I had the same problem and eventually found that the problem was that I had a folder name 'util' and somehow the webpack mixed it with the function util.inhirits. i changed the folder's name and now it is OK.

这篇关于react-share util.inherits 不是 webpack 2 的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆