Home > Mobile >  BREAKING CHANGE: webpack < 5 used to include polyfills for node.js for 'timers-browserify�
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js for 'timers-browserify�

Time:10-31

Hi I'm getting the following error:

./node_modules/xml2js/lib/parser.js:38:17-47 - Error: Module not found: Error: Can't resolve 'timers' in '/Users/differentname/Desktop/workfiles/webdoc/ngx-admin-1/node_modules/xml2js/lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "timers": require.resolve("timers-browserify") }'
        - install 'timers-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "timers": false }

By looking at other existing solutions I tried the following:

  1. Run npm i timers-browserify
  2. In webpack.config.js I added:
module.exports = {
    //
    resolve: {
        fallback: { "timers": false }
    },
};

Does anyone know other ways to solve it?

CodePudding user response:

I solved it by:

npm install --save stream timers

  • Related