Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native node modules from extensions #658

Open
aaronpowell opened this issue Nov 25, 2015 · 42 comments
Open

Native node modules from extensions #658

aaronpowell opened this issue Nov 25, 2015 · 42 comments
Labels
extensions Issues concerning extensions feature-request Request for new features or functionality
Milestone

Comments

@aaronpowell
Copy link

I’m looking to build an extension but one of the packages I need to depend on is a native module. When I do an npm install it installs the package just fine, I can launch a node shell and interact with it, etc. But when I go to use the package from within my plugin I get an error as it’s trying to load the ia32 build of the native module not the x64 which was compiled by node-gyp.

A quick bit of debugging indicates that the problem stems by process.arch returning ia32 when running in VS Code when my machine is a x64 machine (Win10 x64).

So is there some way to either:

  • Have VS Code run an x64 process
  • Have VS Code’s ia32 process do my npm restore (and subsequent compile with node-gyp)

Otherwise I fear that my extension might be dead in the water 😦

@joaomoreno joaomoreno added the feature-request Request for new features or functionality label Nov 26, 2015
@aaronpowell
Copy link
Author

I'm doing some more investigation on this to see if I can unblock myself by getting an ia32 version of the module loaded, so I installed the x86 version of node.js, installed the native module (which in turned got the right binary).

Now I get the following error:

native-module-error

Are native modules not supported in extensions?

@joaomoreno
Copy link
Member

The good: Nothing really.
The bad: Code extensions unfortunately don't support native extensions.
The ugly: There is a workaround. Bear with me:

  • Your native packages must be compiled against the exact same version of node and v8 that Code is. Specifically:
    • npm_config_disturl=https://atom.io/download/atom-shell
    • npm_config_target= whatever value is there on electronVersion
    • npm_config_arch= whatever the bit architecture you need
    • HOME= something other that ~, like ~/.electron-gyp, so node-gyp and npm don't confuse themselves.
  • The extension package must contain the binaries for all platforms Code supports: win32-ia32, darwin, linux-ia32 and linux-x64. It would then dynamically require the correct binary for the running platform at runtime. bindings might help you there.

@joaomoreno joaomoreno removed their assignment Nov 26, 2015
@aaronpowell
Copy link
Author

Yeah I just came across this walkthrough which somewhat outlines the "ugly" side of things 😛.

Native modules are a pain, but I might keep at it and see where I can get to (or see if the native module can be reimplemented in "plain ol' JavaScript", but somehow I don't expect it to be possible.

@joaomoreno
Copy link
Member

We use the npm way in our build scripts, btw.

@aaronpowell
Copy link
Author

I've been playing around with the easy way and got this far:

  • electron-rebuild generated a binary output
  • My extension still failed as the path was not matching the generated output
  • Modified the folder of the generated output and it worked

So - I now have a "working" native node package running in a VSCode extension. But I was curious as to why it wanted a folder of node-v46... to load the binary. It seems that the logic to load the binary uses the node-gyp build/versioning lookup which might be somewhat broken in VSCode. The failure is that internally it does some checks to whether it's node, node-wekbit or electron, but process.versions.electron is undefined in the VSCode plugin. My guess is that because the extension is running out-of-process it's not getting that passed through, which in turn makes it a little unhappy.

Anyway I can at least get the extension launched, so chalk that up to success number 1 😁.

@aaronpowell
Copy link
Author

I've hit another problem that I'm not sure if it's related to it being a native module or if it's another bug, the native module is being reported as not found by VSCode's editor and the TypeScript compiler (when running the package step).

If I run from the debugger it works just fine, the native module is loaded, executed, etc, so I know it's there, but tsc doesn't seem to locate it. I think it's a TypeScript issue than a VSCode issue, but I can't find any info on it. Is it known at the VSCode end?

@joaomoreno
Copy link
Member

It seems that you just need TypeScript typings to go along your native module. Try placing a file in your extension similar to this:

mylib.d.ts

declare module 'mylib' {
    export function foo(arg: number): void;
}

Then, both VSCode and TypeScript would drop the errors when you'd import the module:

import * as mylib from 'mylib';

@aaronpowell
Copy link
Author

ah, I didn't realise you need to have everything with a .d.ts. All sorted and now it's on the marketplace - https://marketplace.visualstudio.com/items/aaronpowell.vscode-espruino (although I'm not sure it'll be installable for anyone else yet).

Is there any way (easy or ugly) to work out the version of Electron when installing a plugin?

@joaomoreno
Copy link
Member

You must always compile it against the version of Electron that VSCode depends on, considering the VSCode version you're targeting. So, for VSCode 0.10.3 it is Electron 0.34.1.

@aaronpowell
Copy link
Author

Yeah I found that out, I'm just trying to avoid shipping a precompiled version of serialport and instead compile it as an install step, but I need to work out what version of VSCode is running (and that tells me what version of Electron)

@joaomoreno
Copy link
Member

Very tricky and it's exactly the reason why we haven't tackled this yet: every user that would install your extension would need the build tooling installed in their system (VS, gcc, etc.).

@aaronpowell
Copy link
Author

Yeah that's a fair point, I guess shipping the compiled module in my extension is probably a good idea (or at least the binary) and get it done for each platform.

I might be able to make an assumption of the build tools (given that it's work working with microprocessors) but it's solid assumption.

@mateodelnorte
Copy link

Is there a mechanism for downloading precompiled binaries as part of the build process, such that extension creators could use a tool to pre-compile an array binaries for different platform and node version targets - and the build process would bring down the appropriate binary and link it?

@joaomoreno
Copy link
Member

node-pre-gyp exists for that purpose when dealing with node modules. But upon installation, we don't call npm install on an extension.

@Tyriar
Copy link
Member

Tyriar commented Aug 1, 2016

So Atom's apm 1.10 beta seems to ship with node and npm now, likely to avoid these exact issues http://blog.atom.io/2016/08/01/atom-1-9-and-1-10-beta.html

@joaomoreno
Copy link
Member

Yep... it's starting to feel inevitable by now.

@aaronpowell
Copy link
Author

I haven't done much with this for a while but my current thinking is that instead of trying to load the native module within the electron shell I think it'll be better to use spawn and uxe the native module from the default node.js install (which obviously requires there to be a node.js install).

I'm thinking this because it seems that the electron-rebuild module no longer works on Windows or with the version of electron being used.

@RLovelett
Copy link

Is there anyway to see the error messages upon faulty loading?

I am trying to make a language server that makes use of a native module. I've followed the steps outlined here and here and have arrived at a module that can be loaded from the extension. So far so good.

However, when my extension starts the server that tries to reference the same native module I get "The Swift server crashed 5 times in the last 3 minutes. The server will not be restarted."

This does not exactly give me a lot to go on to try and resolve where it is going wrong. And the process is dead before I have a chance to attach a debugger to it. If I could just get some messaging about what/why the server is dying that may help me crack the case.

@aaronpowell
Copy link
Author

@RLovelett the problem is now that the version of Electron used in VSCode is a bit out of date (0.37.6 in the insider build of 2016-08-17 that I'm running). It seems that electron-rebuild no longer works with that version (the problem is with nslog dependency) and I'm not sure if it's being maintained.

This is why, for me, I'm thinking of running node in a separate process and passing messages back and forth so I can use a "standard" version of node, rather than the forked version used by electron. Not sure if that'd work in your scenario though.

@meakbiyik
Copy link

I am also dealing with this issue, and there is one thing I do not quite understand why: wouldn't it be easy and perfectly acceptable for vscode to just rebuild all extensions while installing using

npm rebuild --nodedir=/path/to/electron/vendor/node

just as recommended in https://github.com/electron/electron/blob/master/docs/tutorial/using-native-node-modules.md, as this command would do nothing for packages without native node modules, and fix all the issues with the others? I believe it is natural to expect for vscode to fix the node dependency issues since it does not provide access for electron's node to the extension developers, so it should act as a black box.

@ganezdragon
Copy link

hi moderators,

I could rebuild locally and test out my extension. But if I pack and publish it, it doesn't work in the client's machine. Please do let me know if you guys have any solution for publishing.

Thanks!

@pythoulon
Copy link

@ganezdragon for what it's worth, I ask my users to go to the extension folder (~/.vscode/extensions/your-extensions-name-and-version on my Windows machine) after installation/updated, open a terminal there, and type npm install at the command prompt. This will fully rebuild the extension, including compiling the native parts. You have to redo this with every update, but so far it has worked for me every time. You just have to make sure the version of electron you reference tracks the Node.js ABI version, but if you can compile your extension locally, that is normally taken care of.
Good luck...

@ganezdragon
Copy link

@pythoulon thanks for the approach. Yea then I would have to go with this, and hope the users have necessary gcc also to compile it. Or I would have to look at some web bindings (but that has its problem of its own).
But thanks for the quick response pythoulon.

@bmealhouse
Copy link

@ganezdragon @pythoulon - Have either of you tried prebuilding your native node module with prebuildify and then including the binaries in the published npm package? You can use this approach to avoid making your users run npm install inside your extension folder. Make sure you are publishing prebuilds for all platforms and architectures that VS Code supports.

@ganezdragon
Copy link

@bmealhouse, nope I haven't tried it. Let me try it out today and see how that works! Much thanks for telling us about the library.

@pythoulon
Copy link

@bmealhouse Will try it as soon as I get a chance. @ganezdragon please report here on your experience, if you can... Thanks.

@pythoulon
Copy link

@bmealhouse Finally got a chance to take a look at prebuildify. The problem I have is that my extension module is not native per se, but it depends on a couple of native modules. I'm not sure how to use prebuildify in that context. Ideally I would like to deliver my module with the prebuilt versions of those modules (which, as far as I understand, do not come with prebuilt binaries).
Anybody has experience on the matter ? Thanks.

@bmealhouse
Copy link

@pythoulon - You could fork those native modules and prebuildify them for VS code.

@pythoulon
Copy link

@bmealhouse Thanks for the hint. Hadn't thought of it... Will try that.

@samuela
Copy link

samuela commented Oct 17, 2021

I'm running into this issue currently. In particular, I'm trying to use nodegit which has a native dependency on libgit2. At first I was seeing some NODE_MODULE_VERSION mismatch errors. Those were resolved by downgrading my node version to 15.x.

But now I'm seeing an error:

Module did not self-register: '/Users/skainswo/dev/cuddlefish/vscode-extension/node_modules/nodegit/build/Release/nodegit.node'..

Is there a plan for a more robust native dependency solution for VSCode extensions?

@ghost
Copy link

ghost commented Nov 10, 2021

I need help implementing this in a sane manner over at vscode-textmate-languageservice. For some reason, even vscode-test and the getCoreNodeModule snippet refuse to work.

Found C:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\.vscode-test\vscode-winchive-1.62.1. Skipping download.


Warning: 'xshm' is not in the list of known options, but still passed to Electron/Chromium.

[main 2021-11-10T20:33:21.524Z] update#setState idle

Starting extension host with pid 22420.

[LocalProcessExtensionHost]: IExtensionHostStarter.start() took 30 ms.

Error: \\?\c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\node_modules\onigubuild\Release\onig_scanner.node is not a valid Win32 application.
\\?\c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\node_modules\oniguruma\buelease\onig_scanner.node
        at process.func [as dlopen] (electron/js2c/asar_bundle.js:5:1846)
        at Object.Module._extensions..node (internal/modules/cjs/loader.js:1185:18)
        at Object.func [as .node] (electron/js2c/asar_bundle.js:5:1846)
        at Module.load (internal/modules/cjs/loader.js:982:32)
        at Module._load (internal/modules/cjs/loader.js:823:14)
        at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
        at Function.n._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:28606)
        at Function.b._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:25193)
        at Function.h._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:103:60406)
        at Module.require (internal/modules/cjs/loader.js:1006:19)
        at Module.require (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\.v-test\vscode-win32-archive-1.62.1\resources\app\extensions\microsoft-authentication\dist\extension.js:1:38399)
        at require (internal/modules/cjs/helpers.js:88:18)
        at Object.<anonymous> (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice_modules\oniguruma\src\oniguruma.js:3:21)
        at Module._compile (internal/modules/cjs/loader.js:1125:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1155:10)
        at Module.load (internal/modules/cjs/loader.js:982:32)
        at Module._load (internal/modules/cjs/loader.js:823:14)
        at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
        at Function.n._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:28606)
        at Function.b._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:25193)
        at Function.h._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:103:60406)
        at Module.require (internal/modules/cjs/loader.js:1006:19)
        at Module.require (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\.v-test\vscode-win32-archive-1.62.1\resources\app\extensions\microsoft-authentication\dist\extension.js:1:38399)
        at require (internal/modules/cjs/helpers.js:88:18)
        at Object.<anonymous> (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice_modules\first-mate\lib\grammar.js:10:10)
        at Object.<anonymous> (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice_modules\first-mate\lib\grammar.js:395:4)
        at Module._compile (internal/modules/cjs/loader.js:1125:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1155:10)
        at Module.load (internal/modules/cjs/loader.js:982:32)
        at Module._load (internal/modules/cjs/loader.js:823:14)
        at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
        at Function.n._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:28606)
        at Function.b._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:25193)
        at Function.h._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:103:60406)
        at Module.require (internal/modules/cjs/loader.js:1006:19)
        at Module.require (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\.v-test\vscode-win32-archive-1.62.1\resources\app\extensions\microsoft-authentication\dist\extension.js:1:38399)
        at require (internal/modules/cjs/helpers.js:88:18)
        at Object.<anonymous> (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice_modules\first-mate\lib\grammar-registry.js:12:13)
        at Object.<anonymous> (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice_modules\first-mate\lib\grammar-registry.js:273:4)
        at Module._compile (internal/modules/cjs/loader.js:1125:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1155:10)
        at Module.load (internal/modules/cjs/loader.js:982:32)
        at Module._load (internal/modules/cjs/loader.js:823:14)
        at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
        at Function.n._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:28606)
        at Function.b._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:25193)
        at Function.h._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:103:60406)
        at Module.require (internal/modules/cjs/loader.js:1006:19)
        at Module.require (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\.v-test\vscode-win32-archive-1.62.1\resources\app\extensions\microsoft-authentication\dist\extension.js:1:38399)
        at require (internal/modules/cjs/helpers.js:88:18)
        at Object.<anonymous> (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice_modules\first-mate\lib\first-mate.js:4:22)
        at Object.<anonymous> (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice_modules\first-mate\lib\first-mate.js:14:4)
        at Module._compile (internal/modules/cjs/loader.js:1125:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1155:10)
        at Module.load (internal/modules/cjs/loader.js:982:32)
        at Module._load (internal/modules/cjs/loader.js:823:14)
        at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
        at Function.n._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:28606)
        at Function.b._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:25193)
        at Function.h._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:103:60406)
        at Module.require (internal/modules/cjs/loader.js:1006:19)
        at Module.require (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\.v-test\vscode-win32-archive-1.62.1\resources\app\extensions\microsoft-authentication\dist\extension.js:1:38399)
        at require (internal/modules/cjs/helpers.js:88:18)
        at Object.<anonymous> (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservic\src\textmateEngine.js:18:22)
        at Module._compile (internal/modules/cjs/loader.js:1125:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1155:10)
        at Module.load (internal/modules/cjs/loader.js:982:32)
        at Module._load (internal/modules/cjs/loader.js:823:14)
        at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
        at Function.n._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:28606)
        at Function.b._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:25193)
        at Function.h._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:103:60406)
        at Module.require (internal/modules/cjs/loader.js:1006:19)
        at Module.require (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\.v-test\vscode-win32-archive-1.62.1\resources\app\extensions\microsoft-authentication\dist\extension.js:1:38399)
        at require (internal/modules/cjs/helpers.js:88:18)
        at Object.<anonymous> (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservic\test\suite\documentSymbolProvider.test.js:18:26)
        at Module._compile (internal/modules/cjs/loader.js:1125:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1155:10)
        at Module.load (internal/modules/cjs/loader.js:982:32)
        at Module._load (internal/modules/cjs/loader.js:823:14)
        at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
        at Function.n._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:28606)
        at Function.b._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:25193)
        at Function.h._load (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\de-test\vscode-win32-archive-1.62.1\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:103:60406)
        at Module.require (internal/modules/cjs/loader.js:1006:19)
        at Module.require (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\.v-test\vscode-win32-archive-1.62.1\resources\app\extensions\microsoft-authentication\dist\extension.js:1:38399)
        at require (internal/modules/cjs/helpers.js:88:18)
        at c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\node_modules\mochamocha.js:430:36
        at Array.forEach (<anonymous>)
        at Mocha.loadFiles (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\nodules\mocha\lib\mocha.js:427:14)
        at Mocha.run (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\node_mo\mocha\lib\mocha.js:1028:10)
        at c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\out\test\suite\ind:24:23
        at f (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\node_modules\once.js:25:25)
        at Glob.<anonymous> (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\modules\glob\glob.js:148:7)
        at Glob.emit (events.js:315:20)
        at Glob._finish (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\nodeles\glob\glob.js:194:8)
        at done (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\node_modules\glob.js:179:14)
        at Glob._processGlobStar2 (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languagese\node_modules\glob\glob.js:634:12)
        at c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\node_modules\glob\js:623:10
        at RES (c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\node_modules\ght\inflight.js:31:16)

Error: \\?\c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\node_modules\onigubuild\Release\onig_scanner.node is not a valid Win32 application.
\\?\c:\Users\Public\Documents\Code\vscode-textmate-languageservice\test\vscode-matlab\node_modules\vscode-textmate-languageservice\node_modules\oniguruma\buelease\onig_scanner.node
[main 2021-11-10T20:33:31.082Z] Sending IPC message to channel 'vscode:electron-main->shared-process=exit' for shared process window that is destroyed      

Exit code:   1
Done

Failed to run tests

@ghost
Copy link

ghost commented Nov 30, 2021

I found a solution mostly written by MS devs:

'use strict';

import vscode from 'vscode';

/**
 * Returns a node module installed with VSCode, or undefined if it fails.
 */
export default function<T>(id: string): T | null {
	try {
	  return require(`${vscode.env.appRoot}/node_modules.asar/${id}`);
	} catch (err) {
		// ignore
	}

	try {
	  return require(`${vscode.env.appRoot}/node_modules/${id}`);
	} catch (err) {
		// ignore
	}

	return null;
}

deribaucourt added a commit to savoirfairelinux/vscode-bitbake that referenced this issue Feb 19, 2024
node-pty will be used to provider a better interactive terminal.
It's required to have colors and progress bars from bitbake.
Explanation: microsoft/vscode#155444 (comment)

However, VSCode uses electron which has it's own npm
NODE_MODULE_VERSION. I had to use `@electron/rebuild` to match the
version. I wonder if it would break when VSCode updates electron.

There are discussions which failed to provide other workarounds
(we don't use webpack yet):
 - microsoft/node-pty#582
 - microsoft/vscode#658

The format of the files and package-lock.json where updated by npm
install.
deribaucourt added a commit to savoirfairelinux/vscode-bitbake that referenced this issue Feb 20, 2024
node-pty will be used to provider a better interactive terminal.
It's required to have colors and progress bars from bitbake.
Explanation: microsoft/vscode#155444 (comment)

However, VSCode uses electron which has it's own npm
NODE_MODULE_VERSION. I had to use `@electron/rebuild` to match the
version. I wonder if it would break when VSCode updates electron.

There are discussions which failed to provide other workarounds
(we don't use webpack yet):
 - microsoft/node-pty#582
 - microsoft/vscode#658

The format of the files and package-lock.json where updated by npm
install.
deribaucourt added a commit to savoirfairelinux/vscode-bitbake that referenced this issue Feb 20, 2024
VSCode and the Jest native environment use conflicting
NODE_MODULE_VERSION. We have to use node-pty from VSCode
when running in the VSCode environment and the regular
node-pty when running in Jest.

Following the idea presented in:
microsoft/vscode#658 (comment)
We use dynamic imports to load the correct node-pty.

The types must still be imported normally at compile time.
deribaucourt added a commit to savoirfairelinux/vscode-bitbake that referenced this issue Feb 21, 2024
node-pty will be used to provider a better interactive terminal.
It's required to have colors and progress bars from bitbake.
Explanation: microsoft/vscode#155444 (comment)

However, VSCode uses electron which has it's own npm
NODE_MODULE_VERSION. I had to use `@electron/rebuild` to match the
version. I wonder if it would break when VSCode updates electron.

There are discussions which failed to provide other workarounds
(we don't use webpack yet):
 - microsoft/node-pty#582
 - microsoft/vscode#658

The format of the files and package-lock.json where updated by npm
install.
deribaucourt added a commit to savoirfairelinux/vscode-bitbake that referenced this issue Feb 21, 2024
VSCode and the Jest native environment use conflicting
NODE_MODULE_VERSION. We have to use node-pty from VSCode
when running in the VSCode environment and the regular
node-pty when running in Jest.

Following the idea presented in:
microsoft/vscode#658 (comment)
We use dynamic imports to load the correct node-pty.

The types must still be imported normally at compile time.
deribaucourt added a commit to yoctoproject/vscode-bitbake that referenced this issue Feb 21, 2024
node-pty will be used to provider a better interactive terminal.
It's required to have colors and progress bars from bitbake.
Explanation: microsoft/vscode#155444 (comment)

However, VSCode uses electron which has it's own npm
NODE_MODULE_VERSION. I had to use `@electron/rebuild` to match the
version. I wonder if it would break when VSCode updates electron.

There are discussions which failed to provide other workarounds
(we don't use webpack yet):
 - microsoft/node-pty#582
 - microsoft/vscode#658

The format of the files and package-lock.json where updated by npm
install.
deribaucourt added a commit to yoctoproject/vscode-bitbake that referenced this issue Feb 21, 2024
VSCode and the Jest native environment use conflicting
NODE_MODULE_VERSION. We have to use node-pty from VSCode
when running in the VSCode environment and the regular
node-pty when running in Jest.

Following the idea presented in:
microsoft/vscode#658 (comment)
We use dynamic imports to load the correct node-pty.

The types must still be imported normally at compile time.
deribaucourt added a commit to yoctoproject/vscode-bitbake that referenced this issue Feb 27, 2024
node-pty will be used to provider a better interactive terminal.
It's required to have colors and progress bars from bitbake.
Explanation: microsoft/vscode#155444 (comment)

However, VSCode uses electron which has it's own npm
NODE_MODULE_VERSION. I had to use `@electron/rebuild` to match the
version. I wonder if it would break when VSCode updates electron.

There are discussions which failed to provide other workarounds
(we don't use webpack yet):
 - microsoft/node-pty#582
 - microsoft/vscode#658

The format of the files and package-lock.json where updated by npm
install.
deribaucourt added a commit to yoctoproject/vscode-bitbake that referenced this issue Feb 27, 2024
VSCode and the Jest native environment use conflicting
NODE_MODULE_VERSION. We have to use node-pty from VSCode
when running in the VSCode environment and the regular
node-pty when running in Jest.

Following the idea presented in:
microsoft/vscode#658 (comment)
We use dynamic imports to load the correct node-pty.

The types must still be imported normally at compile time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extensions Issues concerning extensions feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests