TypeError: WebAssembly.instantiate(): Import #0 module="env" error: module is not an object or function

TypeError: WebAssembly.instantiate(): Import #0 module="env" error: module is not an object or function

我们目前正在使用 Next.js 和 Three.js(react-three-fiber)进行一个项目。清除浏览器中的缓存后,3d 模型不再显示。 我们得到一些错误。实际上一个警告一个错误(多次)。 错误是

Uncaught (in promise) RuntimeError: abort(TypeError: WebAssembly.instantiate(): Import #0 module="env" error: module is not an object or function). Build with -s ASSERTIONS=1 for more info.

我们确实使用了一些环境变量,但没有特别导入模块“env”。 参数(“-s ASSERTIONS=1”)对我们不起作用。

出现在控制台输出开始处的另​​一个警告是:

failed to asynchronously prepare wasm: TypeError: WebAssembly.instantiate(): Import #0 module="env" error: module is not an object or function

错误有时出现有时不出现,不知道为什么。

感谢任何事情

编辑:

"dependencies": {
  "@heroicons/react": "^1.0.1",
  "@next/env": "^11.1.2",
  "@react-three/drei": "^2.2.13",
  "@tweenjs/tween.js": "^18.6.4",
  "autoprefixer": "^10.2.5",
  "axios": "^0.21.1",
  "drei": "^2.2.13",
  "framer-motion": "^4.1.8",
  "iso-3166-1": "^2.0.1",
  "jwt-decode": "^3.1.2",
  "moment": "^2.29.1",
  "next": "^11.0.0",
  "postcss": "^8.2.12",
  "react": "^17.0.2",
  "react-country-flag": "^2.3.0",
  "react-dom": "^17.0.2",
  "react-fps-stats": "^0.1.3",
  "react-icons": "^4.2.0",
  "react-loader-spinner": "^4.0.0",
  "react-select": "^4.3.1",
  "react-simple-maps": "^2.3.0",
  "react-spring": "^8.0.27",
  "react-three-fiber": "^5.3.11",
  "react-time-ago": "^6.2.2",
  "react-tooltip": "^4.2.21",
  "swr": "^0.5.5",
  "tailwindcss": "^2.1.1",
  "three": "^0.124.0",
 "use-asset": "^1.0.4"
},
"devDependencies": {
  "eslint": "^7.24.0",
  "eslint-config-airbnb": "^18.2.1",
  "eslint-config-next": "^11.0.0",
  "eslint-config-prettier": "^8.2.0",
  "eslint-plugin-jsx-a11y": "^6.4.1",
  "eslint-plugin-prettier": "^3.4.0",
  "eslint-plugin-react": "^7.23.2",
  "eslint-plugin-react-hooks": "^4.2.0",
  "eslint-plugin-security": "^1.4.0",
  "eslint-plugin-simple-import-sort": "^7.0.0",
  "eslint-plugin-sonarjs": "^0.6.0",
  "eslint-plugin-tailwindcss": "^1.13.2",
  "eslint-plugin-unicorn": "^30.0.0",
  "husky": "^6.0.0",
  "lint-staged": "^10.5.4",
  "prettier": "^2.2.1"
}

在我们的例子中,我们将 draco 解码器路径设置为:

https://www.gstatic.com/draco/v1/decoders/

通过调用:

this.dracoLoader.setDecoderPath("https://www.gstatic.com/draco/v1/decoders/");

但他们推荐的方法是在 URL:

中指定版本

https://www.gstatic.com/draco/versioned/decoders/1.4.3/

他们昨天发布了一个新版本,解释了突然出现的错误:https://github.com/google/draco/releases/tag/1.4.3


更改为版本 URL 为我们修复了它。另一个有效的修复是使用 JS 而不是 Webassembly:

this.dracoLoader.setDecoderConfig({ type: "js" });