重大变更:webpack < 5曾为“timers-browserify”包含node.js的polyfills

3

你好,我遇到了以下错误:

./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 }

通过查看其他现有的解决方案,我尝试了以下操作:

  1. 运行 npm i timers-browserify
  2. webpack.config.js 中添加:
module.exports = {
    //
    resolve: {
        fallback: { "timers": false }
    },
};

有没有其他解决方法?

1个回答

1

I solved it by:

npm install --save stream timers


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接