简体   繁体   English

魔术 header 未检测到文件已使用这些加载程序处理:*./node_modules/wasm-loader/index.js

[英]magic header not detected File was processed with these loaders: * ./node_modules/wasm-loader/index.js

I have issue using webassembly wasm file in React with Typescript.我在 React 中使用 webassembly wasm 文件时遇到问题 Typescript。

I have install react-app-rewired and wasm-loader and my config-overrides.js:我已经安装了react-app-rewired rewired 和wasm-loader以及我的 config-overrides.js:

const path = require('path');

module.exports = function override(config, env) {
  const wasmExtensionRegExp = /\.wasm$/;

  config.resolve.extensions.push('.wasm');

  config.module.rules.forEach(rule => {
    (rule.oneOf || []).forEach(oneOf => {
      if (oneOf.loader && oneOf.loader.indexOf('file-loader') >= 0) {
        // make file-loader ignore WASM files
        oneOf.exclude.push(wasmExtensionRegExp);
      }
    });
  });

  // add a dedicated loader for WASM
  config.module.rules.push({
    test: wasmExtensionRegExp,
    include: path.resolve(__dirname, 'src'),
    use: [{ loader: require.resolve('wasm-loader'), options: {} }]
  });

  return config;
};

in package json I change to use "start": "react-app-rewired start", but still have the same error.在 package json 我改用"start": "react-app-rewired start",但仍然有同样的错误。 How can solve this issue?如何解决这个问题? Thank you!谢谢!

"magic header not detected" indicates that your .wasm file is not really a .wasm file. “magic header not detected”表示您的.wasm文件不是真正的.wasm文件。 Can you verify that it is a valid file using wasm-objdump ?您可以使用wasm-objdump验证它是一个有效文件吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Webpack css 加载器问题“!!../../node_modules/css-loader/index.js!./main.css” - Webpack css loader issues "!!../../node_modules/css-loader/index.js!./main.css" Nuxt.js:模块错误(来自./node_modules/eslint-loader/index.js): - Nuxt.js: Module Error (from ./node_modules/eslint-loader/index.js): 错误 in./src/index.js 模块构建失败(来自./node_modules/babel-loader/lib/index.js): - ERROR in ./src/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js): 模块构建失败(来自 ./node_modules/babel-loader/lib/index.js)Vue Js - Module build failed (from ./node_modules/babel-loader/lib/index.js) Vue Js 模块构建失败(来自 ./node_modules/babel-loader/lib/index.js) - Module build failed (from ./node_modules/babel-loader/lib/index.js) 错误:模块构建失败(来自 ./node_modules/babel-loader/lib/index.js):语法错误: - Error: Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: 模块构建失败(来自./node_modules/babel-loader/lib/index.js): - Module build failed (from ./node_modules/babel-loader/lib/index.js): 未捕获的错误:模块构建失败(来自./node_modules/babel-loader/lib/index.js) - Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js) 从 node_modules index.js 导入 class 定义 - import class definitions from node_modules index.js “加载程序Users / abc / node_modules / babel-core / index.js中的错误?{” presets”:[“ react”]}未返回函数” - “ERROR in loader Users/abc/node_modules/babel-core/index.js?{”presets“:[”react“]} didn't return a function ”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM