【问题标题】:Module not found: Error: Can't resolve 'url' in webpack 5/Angular 14找不到模块:错误:无法解析 webpack 5/Angular 14 中的“url”
【发布时间】:2022-06-23 03:02:59
【问题描述】:

在运行 Angular 14 中安装了 [deepstream.io-client-js][1] 的项目时,出现以下错误。 [1]:https://www.npmjs.com/package/deepstream.io-client-js

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: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }```


【问题讨论】:

    标签: angular angular14


    【解决方案1】:

    正如我们在错误中看到的,添加 polyfill 有 2 个步骤,在 tsconfig.jsonwebpack.config.js 文件/strong> 级别并添加如下代码。

    第 1 步。 webpack.config.js

    module.exports = {
      resolve: {
        fallback: { "url": require.resolve("url/") }
      }
    };
    

    步骤 2. 运行 npm i url for - install 'url'

    【讨论】:

      猜你喜欢
      • 2017-07-10
      • 2018-06-25
      • 2016-12-10
      • 2017-12-28
      • 2023-04-11
      • 2017-03-22
      • 1970-01-01
      • 1970-01-01
      • 2021-11-24
      相关资源
      最近更新 更多