我有一个使用Next.js的项目.我需要使用openjphjs解码HTJ2K像素数据.
我将openjphjs.js和openjphjs.wasm添加到项目的一个文件夹中.
我还将以下内容添加到next.js中.
webpack: (config) => {
config.resolve.fallback = { fs: false };
return config;
},
这样做是为了解决以下错误.
Module not found: Can't resolve 'fs'
我按照example年的例子,try 了下面的方法.
import openjphjs from './openjphjs/openjphjs.js';
const = decode = () => {
const decoder = new openjphjs.HTJ2KDecoder();
}
引发了多个错误.
GET http://localhost:3000/_next/static/chunks/openjphjs.wasm 404 (Not Found)
Uncaught (in promise) RuntimeError: Aborted(RuntimeError: Aborted(both async and sync fetching of the wasm failed).
Uncaught TypeError: _openjphjs_openjphjs_js__WEBPACK_IMPORTED_MODULE_8___default(...).HTJ2KDecoder is not a constructor
我try 手动将openjphjs.wasm放置在所示路径中. 我还try 将文件放在/public文件夹中.