重大变更:webpack < 5 used to include polyfills for node.js for 'timers-browserify'

问题描述 投票:0回答:1

您好,我收到以下错误:

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

有谁知道其他方法可以解决这个问题吗?

angular webpack
1个回答
3
投票

我通过运行以下命令解决了这个问题:

npm install --save stream timers

© www.soinside.com 2019 - 2024. All rights reserved.