node.js - Node 模块版本不匹配 : Expected 50

标签 node.js electron

我遇到了这个问题,从全新安装的 Node 和 npm 开始,serial port 包无法加载,Hello World Electron 包中出现以下错误:

enter image description here

我使用的是 Node 6.6.0 版、NPM 3.10.7 版和 OS X 10.11.6。

我查看了我是否过时了,但是查看了 this list ,我找不到任何模块版本为 50 的东西。这是一个错误吗?

我尝试过 npm rebuild,以及删除模块和重新安装,但没有骰子。

更新:即使我运行 node -v 它会打印 v6.6.0,在 Web 控制台中运行 process.versions.node给我 v6.5.0。这是怎么回事?

最佳答案

这是 known issue这是由 serialport 模块使用为不同版本的 Node.js 构建的 native 代码引起的。你可以阅读更多关于插件 here ,如果你有兴趣;它们只是用 C/C++ 编写的模块,可以与 Node 接口(interface),因此模块可以更轻松地与硬件接口(interface)。

该问题提出的解决方案是这样的:

npm rebuild --runtime=electron --target=1.2.5 --disturl=https://atom.io/download/atom-shell --build-from-source

如果您尚未安装 electron-rebuild,这可能有助于确保重建过程正常工作:

npm install --save-dev electron-rebuild

even though when I run node -v it prints v6.6.0, running process.versions.node in the web console gives me v6.5.0. What's going on here?

Electron 使用自己的 Node 版本,但未连接到您的系统 Node 安装(请参阅 homepage 以查看最新 Electron 使用的 Node 版本,或使用 process.versions.node,就像你在问题中所做的那样)。

您可以尝试使用旧版本(可能是 1.1.0,它使用 Chrome 50?),以防出现问题。

关于node.js - Node 模块版本不匹配 : Expected 50,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39547292/

相关文章:

node.js - 使用 Node 将 Azure 应用程序设置作为对象获取?

mysql - TypeOrm - 使用 queryBuilder 的 NestJS

javascript - copyFileSync不复制文件也不抛出错误

javascript - 如何用 Electron fork 子进程

java - 哪个chromedriver版本支持 Electron 应用程序?

mysql - Sequelize 原始查询返回 TextRows 数组

javascript - 如何使用 Gulp 在 Node 中要求 jQuery?

javascript - XMLHttpRequest 无法加载请求的资源上不存在 'Access-Control-Allow-Origin' header 。起源 'http://localhost:3000' 谷歌地图

node.js - 用 Electron 打开一个 Express 应用程序(Nodejs)

javascript - ElectronJS 缓存