napi-rs / node-rs

Node.js bindings ❤️ Rust crates
https://node-rs.dev
MIT License
1.15k stars 34 forks source link

【jieba】Do you need any other dependencies when running on Windows #886

Closed wszgrcy closed 2 months ago

wszgrcy commented 2 months ago

I am testing some features on a newly installed Win10 virtual machine, and the script is as follows. Throwing an exception during runtime. But on machines specifically designed for development, what are the minimum dependencies required to run jieba

在windows上运行时,是否需要其他依赖 我在一个新安装win10的虚拟机上测试一些功能,脚本如下。运行时抛出异常。但是在专门用于开发的机器上正常,请问可以运行jieba的最小环境需要哪些依赖 环境 新的win10系统+fnm node 20.17.0+ "@node-rs/jieba": "^1.10.3" @node-rs/jieba-win32-x64-msvc存在于node_modules

const { load, cut } = require('@node-rs/jieba')

load()
// loadDict(fs.readFileSync(...))
// loadTFIDFDict(fs.readFileSync(...))

cut('我们中出了一个叛徒', false)
Error: Failed to load native binding
    at Object.<anonymous> (C:\Users\chen\Desktop\vm-error-test\node_modules\@node-rs\jieba\index.js:359:11)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (C:\Users\chen\Desktop\vm-error-test\index.js:1:23)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10) {
  [cause]: [
    Error: Cannot find module './jieba.win32-x64-msvc.node'
    Require stack:
    - C:\Users\chen\Desktop\vm-error-test\node_modules\@node-rs\jieba\index.js
    - C:\Users\chen\Desktop\vm-error-test\index.js
        at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
        at Module._load (node:internal/modules/cjs/loader:1051:27)
        at Module.require (node:internal/modules/cjs/loader:1311:19)
        at require (node:internal/modules/helpers:179:18)
        at requireNative (C:\Users\chen\Desktop\vm-error-test\node_modules\@node-rs\jieba\index.js:91:16)
        at Object.<anonymous> (C:\Users\chen\Desktop\vm-error-test\node_modules\@node-rs\jieba\index.js:332:17)
        at Module._compile (node:internal/modules/cjs/loader:1469:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
        at Module.load (node:internal/modules/cjs/loader:1288:32)
        at Module._load (node:internal/modules/cjs/loader:1104:12) {
      code: 'MODULE_NOT_FOUND',
      requireStack: [
        'C:\\Users\\chen\\Desktop\\vm-error-test\\node_modules\\@node-rs\\jieba\\index.js',
        'C:\\Users\\chen\\Desktop\\vm-error-test\\index.js'
      ]
    },
    Error: The specified module could not be found.
    \\?\C:\Users\chen\Desktop\vm-error-test\node_modules\@node-rs\jieba-win32-x64-msvc\jieba.win32-x64-msvc.node
        at Module._extensions..node (node:internal/modules/cjs/loader:1586:18)
        at Module.load (node:internal/modules/cjs/loader:1288:32)
        at Module._load (node:internal/modules/cjs/loader:1104:12)
        at Module.require (node:internal/modules/cjs/loader:1311:19)
        at require (node:internal/modules/helpers:179:18)
        at requireNative (C:\Users\chen\Desktop\vm-error-test\node_modules\@node-rs\jieba\index.js:96:16)
        at Object.<anonymous> (C:\Users\chen\Desktop\vm-error-test\node_modules\@node-rs\jieba\index.js:332:17)
        at Module._compile (node:internal/modules/cjs/loader:1469:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
        at Module.load (node:internal/modules/cjs/loader:1288:32) {
      code: 'ERR_DLOPEN_FAILED'
    }
  ]
}
qhx0825 commented 2 months ago

@wszgrcy Could you please tell me what caused this issue and how it can be resolved?

Yuenmin commented 3 weeks ago

@wszgrcy Could you please tell me what caused this issue and how it can be resolved?

See comment https://github.com/napi-rs/node-rs/issues/632#issuecomment-1214287646