node.js 如何确定我是否安装了 64 位或 32 位节点可执行文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24956691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to determine whether I have 64bit or 32 bit node executable installed?
提问by runtimeZero
On my windows pc I have nodejs installed. I would like to determine whether it is 64 bit or 32 bit. How can one determine that? I executed
在我的 Windows 电脑上,我安装了 nodejs。我想确定它是64位还是32位。如何确定这一点?我执行了
node --help
but that does not seem to have any option to give me the desired information.
但这似乎没有任何选项可以为我提供所需的信息。
回答by Chet
Run this from the command line:
从命令行运行:
node -p "process.arch"
It will return 'arm', 'ia32', or 'x64'.
它将返回“arm”、“ia32”或“x64”。
回答by Sven 31415
If node is installed and executable you can simply run
如果节点已安装且可执行,您只需运行
c:\> node -p "process"
and you should see the content of the processvariable formatted.
There the keys archand platformindicates your operating system. In the example below it's an Windows 7 x64
你应该看到process格式化的变量的内容。那里有键arch和platform指示您的操作系统。在下面的例子中,它是一个Windows 7 x64
{
title : 'Administrator: C:\Windows\System32\cmd.exe - node ',
version : 'v0.10.36',
moduleLoadList :
[ 'Binding evals',
...
'Binding signal_wrap',
'NativeModule string_decoder'],
versions : {
http_parser : '1.0',
node : '0.10.36',
v8 : '3.14.5.9',
ares : '1.9.0-DEV',
uv : '0.10.30',
zlib : '1.2.8',
modules : '11',
openssl : '1.0.1l'
},
arch : 'x64',
platform : 'win32',
argv : ['node'],
execArgv : [],
env : {
ALLUSERSPROFILE : 'C:\ProgramData',
HOMEDRIVE : 'C:',
JAVA_HOME : 'C:\Program Files\Java\jdk1.8.0_05',
NODEJS : 'C:\Program Files (x86)\nodejs\',
NUMBER_OF_PROCESSORS : '4',
OS : 'Windows_NT',
Path : 'C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;',
PATHEXT : '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY',
PROCESSOR_ARCHITECTURE : 'AMD64',
PROCESSOR_IDENTIFIER : 'Intel64 Family 6 Model 42 Stepping 7, GenuineIntel',
PROCESSOR_LEVEL : '6',
PROCESSOR_REVISION : '2a07',
ProgramData : 'C:\ProgramData',
ProgramFiles : 'C:\Program Files',
'ProgramFiles(x86)' : 'C:\Program Files (x86)',
ProgramW6432 : 'C:\Program Files',
PROMPT : '$P$G',
PUBLIC : 'C:\Users\Public',
PYTHON : 'C:\Python34',
SESSIONNAME : 'Console',
SystemDrive : 'C:',
SystemRoot : 'C:\Windows',
windir : 'C:\Windows',
windows_tracing_flags : '3'
},
features : {
...
},
config : {
...
}
}
回答by onelaview
If it's on Windows OS, just go an old-school way.. by using Windows Task Manager.
如果它在 Windows 操作系统上,只需使用老派的方式..使用Windows 任务管理器。
Here is my attempt:-
这是我的尝试:-
Simply run nodefrom command prompt.
只需node从命令提示符运行。
C:\> node
C:\> node
This will put node into REPL mode (indicated by >symbol).
Now open Task Manager (Ctrl+Shift+Esc) to see node.exeprocess details. Mine is on Windows 10 64-bit with node 32-bit installed. Make sure you enable 'Platform' column to see 32-bit/64-bit information.
这将使节点进入 REPL 模式(由>符号表示)。现在打开任务管理器 (Ctrl+Shift+Esc) 以查看node.exe进程详细信息。我的是安装了 32 位节点的 Windows 10 64 位。确保启用“平台”列以查看 32 位/64 位信息。
回答by HDK
in mac
在 mac
$ node
> require('os').arch()
in windows
在窗户里
c:\> node
> require('os').arch()
回答by meShakti
Well the way I am suggesting is not at all a good way . You can go over to C: then go to Program Files and search nodejs folder there . If it is found then you are running 64 bit version else check on Program Files (x86) . If it is found there then you are running 32 bit version.
那么我建议的方式根本不是一个好方法。您可以转到 C: 然后转到 Program Files 并在那里搜索 nodejs 文件夹。如果找到,那么您正在运行 64 位版本,否则请检查 Program Files (x86) 。如果在那里找到,那么您正在运行 32 位版本。
回答by jez
This likely doesn't directly solve your problem, as I don't know the best way to get the same behavior on Windows, but using the filecommand on a Unix or Linux system will tell you the processor architecture of an executable:
这可能不会直接解决您的问题,因为我不知道在 Windows 上获得相同行为的最佳方法,但是file在 Unix 或 Linux 系统上使用该命令会告诉您可执行文件的处理器架构:
$ file `which node`
/usr/local/bin/node: Mach-O 64-bit executable x86_64
If you have Cygwin installed, I'm pretty sure that it provides a filecommand, or else you could check online for similar programs that work on Windows.
如果您安装了 Cygwin,我很确定它提供了一个file命令,否则您可以在线检查在 Windows 上运行的类似程序。
回答by Siva Tumma
Just start node interpreter by running node. then in that, process.envgives a json with all the information you require. My try has a PROCESSOR_ARCHITECTURE: 'AMD64'entry in that.
只需通过运行启动节点解释器node。然后在其中process.env提供一个包含您需要的所有信息的 json。我的尝试中有一个PROCESSOR_ARCHITECTURE: 'AMD64'条目。
I also find
我也发现
ProgramFiles: 'C:\\Program Files', 'ProgramFiles(x86)': 'C:\\Program Files (x86)'ProgramW6432: 'C:\\Program Files'
ProgramFiles: 'C:\\Program Files', 'ProgramFiles(x86)': 'C:\\Program Files (x86)'ProgramW6432: 'C:\\Program Files'
回答by Debajyoti Dutta
Enter the node REPL using the 'node' command.
使用“node”命令输入节点 REPL。
The prompt will change to >
提示将变为 >
Then use the following to get the desired info-
然后使用以下内容获取所需的信息-
- require('process').arch ==> this will give the node architecture version.
- require('process').platform ==> this will give the architecture of the compilation platform
- require('process').release and require('process').release.libUrl ==> also gives information about the version and achitecture
- require('process').config.variables.host_arch ==> this will also give the node architecture version.
- require('process').arch ==> 这将给出节点架构版本。
- require('process').platform ==> 这将给出编译平台的架构
- require('process').release 和 require('process').release.libUrl ==> 还提供有关版本和架构的信息
- require('process').config.variables.host_arch ==> 这也将给出节点架构版本。


