Error: Module version mismatch. Expected 47, got 48

Error: Module version mismatch. Expected 47, got 48

我正在编写一个 Visual Studio 代码扩展,它使用本机 node.js 模块。当我尝试在 vscode 中调试此扩展时,我在加载本机模块时从上面收到错误消息(当注释掉 require() 调用时没有出现错误)。它尝试了很多步骤来克服+测试这个:

我仍然无法 vscode 接受我的原生模块。我能做什么?从上述步骤看来,vscode 似乎是使用介于当前和 LTS 之间的 node.js 版本构建的。我可以强制我的原生模块以某种方式使用特定版本吗?

顺便说一句。这些数字 48、47、46 等到底是什么意思? node.js 版本当然是典型的形式:major.minor.build 并且与上述版本号没有任何匹配。

更新:

好的,我找到了这些数字的含义:https://nodejs.org/en/download/releases/

一旦您知道错误消息中的这些数字的含义,就很容易解决问题。只需安装预期的 node.js 版本。在我的例子中是 node.js 5.12.0.

删除 node_modules 文件夹

运行 npm update

然后;

运行 npm install