Node.js 无法使用Electron使用leveldown包

Node.js 无法使用Electron使用leveldown包,node.js,npm,electron,leveldown,Node.js,Npm,Electron,Leveldown,当我尝试使用electron构建应用程序时,它在leveldown库上崩溃 Error: The module '/Users/macosx/Documents/Electron/node_modules/leveldown/build/Release/leveldown.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 64. This version of Node.js requ

当我尝试使用electron构建应用程序时,它在leveldown库上崩溃

Error: The module '/Users/macosx/Documents/Electron/node_modules/leveldown/build/Release/leveldown.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 67. Please try re-compiling or re-installing
我试过了

rm -rf node_modules/leveldown
npm install



我也试过这个

我也有同样的问题,这里提到的任何东西都不适合我。以下是>为我工作的内容:

需要运行的main.js文件中所需的所有依赖项 电子。(这似乎是我的第一个重要部分)运行npm i-D electron rebuild以添加electron rebuild包并删除 节点模块文件夹以及packages-lock.json文件。运行npm i 安装所有模块。运行./node_modules/.bin/electron重建到 重建一切运行起来非常重要 ./node_modules/.bin/electron在npm i之后直接重建,否则会 没有在我的mac上工作


我为此挣扎了几天。诀窍是用于构建本机节点模块,并将该选项包括在您的网页包配置中,因为降级取决于节点提供的_dirname global。

非常感谢您的回答,但您能否详细说明一下,您是否只运行了electron rebuild或手动添加的节点。\uuuu dirname?此答案假设您的生成例程正在使用webpack,如果是,您应该有一些文件,例如
webpack.base.config.js
,其中包含webpack用于生成的参数。在这些文件中,将有一个
节点
部分,您需要在该嵌套对象中将
\u dirname
的值设置为
true
。完成后,当您重新运行electron rebuild时,它应该具有正确定义的(环境)
\uuuDirName
变量,这是leveldown构建过程所需的。感谢您的uuDirName技巧!!!!!谢谢谢谢谢谢!!
npm rebuild leveldown--update-binary
npm uninstall leveldown