Search code examples
javascriptnode.jsreactjsnpmcheerio

Cannot read property 'Tag' of undefined. from domhandler in react.js app


I have a react.js project, which indirectly uses domhandler v4.2.0 via cheerio.

Its worked fine for months and then suddenly, my project has started throwing this error when I try to build it.

Tag exists within domelementtype package...and I haven't touched these at all, because they are child dependencies of the main packages I imported originally.

C:\product-app\node_modules\domhandler\lib\node.js:32
    [domelementtype_1.ElementType.Tag, 1],
                                  ^

TypeError: Cannot read property 'Tag' of undefined
    at Object.<anonymous> (C:\product-app\node_modules\domhandler\lib\node.js:32:35)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (C:\product-app\node_modules\domhandler\lib\index.js:15:14)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)

Any ideas what might be causing it?

I'm running node.js 12.16.1 with typescript 3.9.10. The project was originally built on create-react-app and I haven't changed anything, so something in my local environment must have changed to cause this.

I have tried:

  • clearing the node_modules (rimraf)
  • clearing npm cache (inc --force)
  • wiping out my local git repo and pulling a fresh
  • changing node versions
  • installing typescript globally
  • rebooting

Solution

  • Try to use 1.0.0-rc.3. There was some breaking changes between that version and the latest.