Is it possible to know NODE_MODULE_VERSION
in Node.js? If yes, then how?
I am interested specifically in the VSCode's builtin Node.js, but maybe Node.js doesn't expose the variable, but VSCode API does?
Asked
Active
Viewed 3,624 times
7

Nurbol Alpysbayev
- 19,522
- 3
- 54
- 89
-
Does this answer your question? [Visual Studio Code to use node version specified by NVM](https://stackoverflow.com/questions/44700432/visual-studio-code-to-use-node-version-specified-by-nvm) – Wassim Ben Hssen Dec 05 '19 at 10:51
-
1@J.Meijer Thanks, but that's not even close. – Nurbol Alpysbayev Dec 05 '19 at 10:53
-
1@Was'SiimBenHssen No it doesn't. – Nurbol Alpysbayev Dec 05 '19 at 10:53
-
Will do, but from your question, it sounded like you want to do this programmatically? – Lawrence Cherone Dec 05 '19 at 11:04
1 Answers
12
To access in node what electron refers to as NODE_MODULE_VERSION
, you use:
process.versions.modules
Other values in that object:
> console.log(process.versions)
{
"http_parser": "2.8.0",
"node": "8.16.2",
"v8": "6.2.414.78",
"uv": "1.23.2",
"zlib": "1.2.11",
"ares": "1.10.1-DEV",
"modules": "57",
"nghttp2": "1.39.2",
"napi": "4",
"openssl": "1.0.2s",
"icu": "60.1",
"unicode": "10.0",
"cldr": "32.0",
"tz": "2017c"
}

Lawrence Cherone
- 46,049
- 7
- 62
- 106
-
1Great, I didn't know what is the relation between `NODE_MODULE_VERSION` and `process.versions.modules`. You defined that in the first sentence "what electron refers to as". – Nurbol Alpysbayev Dec 05 '19 at 11:10
-
1FYI- to get this from command line, you can do `node -e "console.log(process.versions)"` – Kip Apr 14 '22 at 18:54
-
5
-
1If I need the nodejs `NODE_MODULE_VERSION` to match the electron `NODE_MODULE_VERSION` (the same module needs to be shared used by both electron and nodejs modules) can I assume I need the node.js version to match the electron version? – Michael Nov 07 '22 at 00:17