尝试修复不同节点模块版本错误时 npm rebuild 不起作用
npm rebuild doesn't work when trying to fix different node module version error
我在 better_sqlite3 包使用不同版本的节点时遇到错误,它说尝试 npm rebuild
和 npm install
但这并没有解决任何问题我仍然遇到同样的错误。
/home/nonce/Documents/Repositories/test/node_modules/bindings/bindings.js:121
throw e;
^
Error: The module '/home/nonce/Documents/Repositories/test/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 102. This version of Node.js requires
NODE_MODULE_VERSION 93. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at bindings (/home/nonce/Documents/Repositories/test/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/home/nonce/Documents/Repositories/test/node_modules/better-sqlite3/lib/database.js:9:24)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32) {
code: 'ERR_DLOPEN_FAILED'
}
我不认为这是 better-sqlite3 本身的错误,因为我做了一些研究并且很多人都遇到过这种错误,一般的解决方案是执行 npm rebuild
但对我来说这没有任何作用。
解决了这个问题,我使用的是节点 v16.13.2 的过时版本,所以我尝试切换到最新版本(截至目前为 v17.4.0),它现在工作得很好。
我在 better_sqlite3 包使用不同版本的节点时遇到错误,它说尝试 npm rebuild
和 npm install
但这并没有解决任何问题我仍然遇到同样的错误。
/home/nonce/Documents/Repositories/test/node_modules/bindings/bindings.js:121
throw e;
^
Error: The module '/home/nonce/Documents/Repositories/test/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 102. This version of Node.js requires
NODE_MODULE_VERSION 93. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at bindings (/home/nonce/Documents/Repositories/test/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/home/nonce/Documents/Repositories/test/node_modules/better-sqlite3/lib/database.js:9:24)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32) {
code: 'ERR_DLOPEN_FAILED'
}
我不认为这是 better-sqlite3 本身的错误,因为我做了一些研究并且很多人都遇到过这种错误,一般的解决方案是执行 npm rebuild
但对我来说这没有任何作用。
解决了这个问题,我使用的是节点 v16.13.2 的过时版本,所以我尝试切换到最新版本(截至目前为 v17.4.0),它现在工作得很好。