webpack: Error `Uncaught TypeError: util.inherits is not a function`
I want to use console.log
in my script, so I added node: { console: true }
to my configuration. Now when I try to load the script, it reports Uncaught TypeError: util.inherits is not a function
. The error is occuring in the Webpack version of assert.js
at the line:
util.inherits(assert.AssertionError, Error);
I nosed around a bit, and it seems that that file is being parsed twice (if I put a log statement at the top of the file, it is written to the console twice). The first time, the util
object is correct and has an inherits
property that is a function. The second time, util
is still an object but it has no properties.
Does anyone have an idea what might be going on here? If not, I will try to put together a simple reproducible use case.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 4
- Comments: 15 (3 by maintainers)
Commits related to this issue
- Fix util.inherits is not a function ...a webpack issue. see https://github.com/webpack/webpack/issues/1019 — committed to junjiah/ybk-map by junjiah 7 years ago
This is seriously annoying :hurtrealbad:. I did this in the end, because the
node-util
probably won’t ever get updated again:Then in your config, monkeypatch
node-libs-browser
:Adding this to the webpack config solved it for me.
i got this error becasue i had an
util
folder in my repository in which i created anindex.ts
/index.js
which overshadowed thenode_module/util
module. Solved it by just renaming that index.ts thereby preventing my ./util to pass as a node module.npm i --save util@0.10.0 works for me temporally
I am also was to run
cd node_modules/node-libs-browser && npm i util@0.10.0