Nx Angular 微前端构建错误:“找不到模块:错误:无法解析”http“...”

Nx Angular microfrontend Build Error: "Module not found: Error: Can't resolve 'http' in..."

提问人:Federico Pared 提问时间:11/15/2023 最后编辑:Federico Pared 更新时间:11/15/2023 访问量:26

问:

我正在尝试使用模块联合实现将 Cesium 添加到我的微前端项目中。 我已经安装了铯(不是角铯),但是当我尝试这样做时,我收到以下错误:npx nx serve shell --devRemotes=map,admin

Module not found: Error: Can't resolve 'zlib' in '..\node_modules\@cesium\engine\Source\Core'

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

Error: Module not found: Error: Can't resolve 'https' in '..\node_modules\@cesium\engine\Source\Core'

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

Error: Module not found: Error: Can't resolve 'http' in '..\node_modules\@cesium\engine\Source\Core'

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

我试图用这个解决方案来解决它:

来自铯的铯社区 git 来自铯 来自铯

但这些都对我有用。

这是该项目的 StackBlitz:StackBlitz

有谁知道我做错了什么?

提前致谢!

Angular CesiumJS 微前端 NX-Workspace

评论


答: 暂无答案