一些上下文
每次发布基于新版本 Node 的 VS Code 时,VS Code Arduino 扩展都会中断,直到发布新版本。
克隆了 Arduino 扩展 git repo 后,我将其作为扩展卸载并在调试器中运行。这行得通,现在我有了特定的情报,只要我知道如何采取行动就好了。这是消息:
[Warn] no library available after trying files native_loader.js
undefined
Array[3]
0
"d:/vscode-arduino/out/node_modules/node-usb-native/lib/native/detector_darwin_7.1.11_x64.node"
1
"d:/vscode-arduino/out/node_modules/node-usb-native/lib/native/detector_Ubuntu14.04_7.1.11_x64.node"
2
"d:/vscode-arduino/out/node_modules/node-usb-native/lib/native/detector_win32_7.1.11_x64.node"
rejected promise not handled within 1 second: Error: The module '\\?\d:\vscode-arduino\out\node_modules\usb-detection\build\Release\detection.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 80. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
extensionHostProcess.js
stack trace: Error: The module '\\?\d:\vscode-arduino\out\node_modules\usb-detection\build\Release\detection.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 80. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
这些文件中的最后一个(Windows x64 文件)确实存在于预期路径上,因此“没有可用的库”并不意味着它找不到该文件。这与报告找不到合适版本的消息的结尾一致。
这条消息的结尾表明npm rebuild
,或者npm i
我尝试了这些都无济于事。
翻箱倒柜package.json
_
"scripts": {
"vscode:prepublish": "gulp build --mode=production",
"postinstall": "cd ./src/views && npm install && node ../../node_modules/node-usb-native/scripts/rebuild-serialport.js",
"test": "gulp test"
},
"extensionDependencies": [
"ms-vscode.cpptools"
],
"devDependencies": {
"@types/compare-versions": "^3.0.0",
...
"webpack": "^4.44.1"
},
"dependencies": {
...
"node-usb-native": "0.0.13",
...
}
依赖于node-usb-native
最新的(0.0.15)。更改它并运行npm i
会触发rebuild-serialport.js
似乎成功的安装后任务,但我在运行时遇到相同的错误。
问题
我该如何解决这个问题?
- 究竟需要重建什么?
usb-detection
未在依赖项(或 devDependencies)中列出,但如果我没记错的话node-usb-native
,取决于它。 - 我该如何解决这个问题,以便抱怨版本的代码看到新生成的位?