在Angular 10中使用ICE

问题描述

我正在尝试在Angular 10应用程序中使用zeroC ICE。 刚刚创建了一个简单的helloworld Angular应用,并使用“ npm install ice”安装了ice 然后,我调用“ Ice.initialise()”,但收到以下错误:

ModuleRegistry.js:25 Uncaught TypeError: m.require is not a function
    at ModuleRegistry.js:25
    at Array.forEach (<anonymous>)
    at Function.require (ModuleRegistry.js:23)
    at Object.<anonymous> (Ice.js:7)
    at Object../node_modules/ice/src/Ice/Ice.js (Ice.js:45)
    at __webpack_require__ (bootstrap:79)
    at Object../node_modules/ice/src/index.js (index.js:5)
    at __webpack_require__ (bootstrap:79)
    at Module../src/app/app.component.ts (main.js:109)
    at __webpack_require__ (bootstrap:79)

解决方法

我已经在ICE git上发布了相同的问题。

基本上,您需要:

  • 更新项目以包括Ice库的浏览器版本。
  • 更新内部版本以使用自定义的webpack配置,这需要@ angular-builders / custom-webpack。
  • 在自定义Webpack配置中,将ice设置为外部模块,这样导入不会导致生成节点版本。

这是详细的解决方案:

https://github.com/zeroc-ice/ice/issues/1039

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...