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 1,893 times
6
Nurbol Alpysbayev
- 16,001
- 2
- 41
- 68
-
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
-
@J.Meijer Thanks, but that's not even close. – Nurbol Alpysbayev Dec 05 '19 at 10:53
-
@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
9
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
- 44,769
- 7
- 56
- 100
-
Great, 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
-
FYI- to get this from command line, you can do `node -e "console.log(process.versions)"` – Kip Apr 14 '22 at 18:54
-
2