node.js - 依赖于 vscode 模块中的大量 npm…?

标签 node.js scala npm visual-studio-code ensime

我刚刚开始尝试将 Ensime scala ide 支持集成到 vscode 中。我已经从我的 Atom 包 https://github.com/ensime/ensime-atom 中取出了一些集成部分进入https://github.com/ensime/ensime-node .

但是,当从 vscode 依赖于此时,我得到红色波浪线,表明找不到它: reds

但是,代码仍然可以正常构建和运行。我很担心。我发现了这个:

Q: Can I use native Node.js modules with my extension?

A: A Visual Studio Code extension package contains all of its dependencies. This means that if you develop your extension on Windows and depend on a native Node.js module when you publish that extension, the Windows compiled native dependency will be contained in your extension. Users on OS X or Linux won't be able to use the extension.

The only way to make this work for now is to include binaries for all four platforms of VS Code (Windows x86 and x64, Linux, OS X) in your extension and have code that dynamically loads the right one.

这是什么意思?我不能使用fs、net、child_process之类的吗?我认为有点需要它们,还是 vscode 通过抽象层提供所有这些?

最佳答案

您确实已经包含了基本 Node 模块(fs 等)作为 vscode 本身依赖项的一部分。

您是否记得将此模块作为依赖项包含在您的 package.json 文件中?

检查这一点的方法是清理代码,将其放入新文件夹中,然后运行“npm install” - 如果一切运行正常,则可以开始。

请参阅此文档: https://code.visualstudio.com/Docs/extensionAPI/extension-manifest

请务必阅读最新版本中的新扩展创作更新:https://code.visualstudio.com/Updates

关于node.js - 依赖于 vscode 模块中的大量 npm…?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35798211/

相关文章:

npm - 无法使用 npm 安装,因为 openshift 中的权限

javascript - console.log 不是 nodejs fs.readfile 中的函数

javascript - 在嵌套 for 循环中获取值 - node.js、javascript、redis、Q 库

sockets - 握手后立即发送 WebSocket 消息

scala - 如何使我的排序函数尾递归?

scala - Foreach/Map block 中的抛出异常

javascript - 数据关闭时 npm run watch 无法编译

node.js - 将 Webpack 添加到现有 React 应用程序

Scala Play Framework 2.1 Slick 1.0 Cake 模式公用表字段

node.js - npm:为什么版本 "0.1"无效?