“ serialport”节点模块版本错误消息令人困惑

时间:2018-11-23 20:21:41

标签: node.js

以下节点错误是否表示我需要升级串行端口模块,降级nodejs或其他? (它一直有效,直到我将ubuntu从16.04更新到18.04为止)

Error: The module '../node_modules/@serialport/bindings/build/Release/bindings.node' 
was compiled against a different Node.js version using 
NODE_MODULE_VERSION 67. This version of Node.js requires 
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).

我尝试过:

rm package-lock.json;
rm -rf node_modules;
npm install
npm rebuild
npm install serialport --build-from-source
sudo npm install serialport --unsafe-perm --build-from-source

有一种简单的方法可以解决此问题吗?

1 个答案:

答案 0 :(得分:1)

完全删除了nodejs npm,重新安装,运行nodejs main.js,然后根据需要使用npm安装了软件包。现在可以工作。