我知道还有另一个这样的问题,但是这些答案对我来说都不起作用。
这是错误:
Uncaught Error: The module '/Users/sheshankshankar/Documents/serial-monitor-app/node_modules/@serialport/bindings/build/Release/bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 70. This version of Node.js requires
NODE_MODULE_VERSION 73. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at process.func (electron/js2c/asar.js:155)
at process.func [as dlopen] (electron/js2c/asar.js:155)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:828)
at Object.func (electron/js2c/asar.js:155)
at Object.func [as .node] (electron/js2c/asar.js:155)
at Module.load (internal/modules/cjs/loader.js:645)
at Function.Module._load (internal/modules/cjs/loader.js:560)
at Module.require (internal/modules/cjs/loader.js:685)
at require (internal/modules/cjs/helpers.js:16)
at bindings (/Users/sheshankshankar/Documents/serial-monitor-app/node_modules/bindings/bindings.js:112)
代码在这里。请执行以下操作将其安装。
git clone https://github.com/GreenBayRules/serial-monitor-app.git
# Go into the repository
cd serial-monitor-app
# Install dependencies
npm install
# Run the app
npm start
但事实并非如此。我得到那个错误。我尝试了以下方法:
npm install
npm rebuild
yarn install --force
删除node_modules
此处几乎所有其他答案:Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51
我的节点版本为v10.16.3
答案 0 :(得分:1)
我在电子方面面临着同样的错误 bindings.node使用NODE_MODULE_VERSION 72针对不同的Node.js版本进行编译。此版本的Node.js需要NODE_MODULE_VERSION 75。
在Windows 7上,使用电子7。我通过电子生成器解决了它。
我在package.json中的脚本
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"electron": "ng build --base-href ./ && tsc --p electron && electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder"
},
运行“ npm run dist”解决了该问题
答案 1 :(得分:0)
首先使用 npm i electron electron-builder 安装电子和电子生成器,然后将此依赖项移动到 devdependencies 中,然后运行以下脚本