Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a 模块未找到 #316

Closed
UtherPim opened this issue Nov 20, 2023 · 5 comments
Closed

a 模块未找到 #316

UtherPim opened this issue Nov 20, 2023 · 5 comments

Comments

@UtherPim
Copy link

env: macos M1
node@16.8
electron@16.0.2

import { createExtractorFromFile } from 'node-unrar-js/esm';
const wasmBinary = fs.readFileSync(require.resolve('node-unrar-js/esm/js/unrar.wasm'));

const extractor = await createExtractorFromFile({
wasmBinary,
filepath,
targetPath
});

运行报错:
This dependency was not found:

  • a in ./node_modules/node-unrar-js/esm/js/unrar.wasm

To install it, you can run: npm install --save a
ERROR Build failed with errors.

@YuJianrong
Copy link
Owner

@UtherPim
Please provide a sample project to reproduce your bug report.

@UtherPim
Copy link
Author

在src/background.js下打开注释: // import { createExtractorFromFile } from 'node-unrar-js/esm'
归档.zip

@YuJianrong
Copy link
Owner

It seems the webpack in your project (installed by vue) tries to parse the .wasm file as a js file and it's failed. Maybe you need to upgrade your bundler to a new version and try again.

@YuJianrong
Copy link
Owner

The asm.js version is enabled in beta channel, please try to install the beta version by:

npm install node-unrar-js@beta

And use the asm.js version like this example in your code:

import { createExtractorFromData } from 'node-unrar-js/esm-asm'
import fs from 'fs'

const rarFile = fs.readFileSync('./WithComment.rar')
async function extract() {
    const extractor = await createExtractorFromData({data: rarFile})
    const {fileHeaders} = extractor.getFileList()
    console.log([...fileHeaders])
}

@UtherPim
Copy link
Author

UtherPim commented Dec 4, 2023

谢谢,新版本可以执行了,但是还是有解压问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants