1

I'm just starting out trying to integrate Ensime scala ide-support into vscode. I have pulled out some of the integration parts from my atom package https://github.com/ensime/ensime-atom into https://github.com/ensime/ensime-node.

However, when depending on this from vscode I get red squigglies that it can't be found: reds

However, code still build and runs just fine. I got worried. I found this:

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.

What does this mean? I can't use fs, net, child_process and the like? Kindof need them all I think or does vscode provide all that through abstraction layers?

marcospereira
  • 12,045
  • 3
  • 46
  • 52
Viktor Hedefalk
  • 3,572
  • 3
  • 33
  • 48

1 Answers1

1

You do have the basic node modules (fs, etc) already included as part of the dependency of vscode itself.

Did you remember to include this module in your package.json file as a dependency?

A way to check this would be to clean your code, put it in a new folder, and run "npm install" - if everything then runs fine, you are good to go.

See this docs: https://code.visualstudio.com/Docs/extensionAPI/extension-manifest

Be sure to also read up on the new extension authoring update in the latest version: https://code.visualstudio.com/Updates

Tobiah Zarlez
  • 1,680
  • 1
  • 12
  • 13
  • Yes, it's in package.json, node_modules and it actually do run. But I can't get rid of the error report in the vscode. – Viktor Hedefalk Mar 04 '16 at 20:28
  • But can I depend on a package that depends on say child_process? I that what apm rebuild fixes in the case of atom? – Viktor Hedefalk Mar 04 '16 at 21:23
  • If your package has its dependencies written correctly, they will all be included. I myself have an extension that uses child_process – Tobiah Zarlez Mar 04 '16 at 21:27
  • Ok, cool. I think I see trouble though. I guess what this quote means is that, sure standard node modules are provided by the engine (like child_process), but if you depend on anything that's cross-built with node-gyp for instance that isn't part of node standard install, that will be packaged in your bundle at publish time and your screwed. I think I have a few of those, like chokidar for file watching. If I publish from my mac, my package will blow on Windows. – Viktor Hedefalk Mar 04 '16 at 22:17