错误:wasm的异步和同步获取均失败

时间:2019-09-25 08:08:47

标签: angular ionic4 hybrid-mobile-app typeorm sql.js

我正在IONIC4中开发混合应用程序。对数据库使用typeorm。重叠错误

core.js:9110 ERROR Error: Uncaught (in promise): abort("abort(\"both async and sync fetching of the wasm failed\"). Build with -s ASSERTIONS=1 for more info."). Build with -s ASSERTIONS=1 for more info.
at resolvePromise (zone-evergreen.js:797)
at zone-evergreen.js:862
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:34182)
at ZoneDelegate.invokeTask (zone-evergreen.js:390)
at Zone.runTask (zone-evergreen.js:168)
at drainMicroTaskQueue (zone-evergreen.js:559)

我在Google搜索了很多东西。我浪费了时间。但是没有得到任何解决方案。请给我建议。

2 个答案:

答案 0 :(得分:2)

将已编译的文件(starfield.html,starfield.js,starfield.wasm)放入Web服务器并使用http运行。 enter image description here

答案 1 :(得分:0)

Angular 12 和 ionic 5 也有同样的问题,我认为这可能是由 webpack 和 sql.js 引起的。这里是我的 custom.webpack.config.js:

const webpack = require('webpack');
console.log('The custom config is used');
module.exports = {
    plugins: [
        new webpack.ProvidePlugin({
            'window.SQL': 'sql.js/dist/sql-wasm.js'
        }),
        new webpack.NormalModuleReplacementPlugin(/typeorm$/, function (result) {
            result.request = result.request.replace(/typeorm/, "typeorm/browser");
        })
    ],
   
    resolve: {
        fallback: {
          fs: false,
          net: false,
          tls: false
        }
      }
};