Node.jsのprocess.arch()メソッド
process.arch()メソッドは、現在のnode.jsプロセスのコンパイルが行われているコンピューターのCPUアーキテクチャーを取得するために使用されます。同じものに使用できる値には、「arm」、「arm64」、「ia32」、「mips」、「mipsel」、「ppc」、「ppc64」、「x32」、「x64」などがあります。
構文
process.arch()
パラメータ
コンパイルが行われているコードのアーキテクチャを返すためです。入力は必要ありません。アーキテクチャ名を返すだけです。
例
名前がarchitecture.jsのファイルを作成し、以下のコードスニペットをコピーします。ファイルを作成したら、次のコマンドを使用して、以下の例に示すようにこのコードを実行します-
node architecture.js
archive.js
// Node.js program to demonstrate the use of process.arch
// Importing the process module
const process = require('process');
// Printing the arch of given system
console.log(process.arch); 出力
C:\home\node>> node architecture.js x64
例
もう1つの例を見てみましょう。
// Node.js program to demonstrate the use of process.arch
// Importing the process module
const process = require('process');
// Printing the value for given architecture
switch(process.arch) {
case 'x32':
console.log("This is a 32-bit extended systems");
break;
case 'x64':
console.log("This is a 64-bit extended systems");
break;
case 'arm':
console.log("This is a 32-bit Advanced RISC Machine");
break;
case 'arm64':
console.log("This is a 64-bit Advanced RISC Machine");
break;
case 'mips':
console.log("This is a 32-bit Microprocessor without " + "Interlocked Pipelined Stages");
break;
case 'ia32':
console.log("This is a 32-bit Intel Architecture");
break;
case 'ppc':
console.log("This is a PowerPC Architecture.");
break;
case 'ppc64':
console.log("This is a 64-bit PowerPC Architecture.");
break;
// You can add more architectures if you know...
default:
colsole.log("This architecture is unknown.");
} 出力
C:\home\node>> node architecture.js This is a 64-bit extended systems
-
Node.jsのprocess.argv0()メソッド
process.argv0()メソッドは、node.jsアプリケーションの起動時に渡されるargv[0]の元の値の読み取り専用コピーを保存するために使用されます。 構文 process.argv0() パラメータ argv[0]のプリペイドカードの読み取り専用コピーのみを返すため。ユーザーからの入力は必要ありません。 例 argv0.jsという名前のファイルを作成し、以下のコードスニペットをコピーします。ファイルを作成したら、次のコマンドを使用して、以下の例に示すようにこのコードを実行します- node argv0.js argv0.js // Node.js program to
-
Node.jsのprocess.argv()メソッド
process.argv()メソッドは、Node.jsプロセスの起動時に渡されたすべてのコマンドライン引数を返すために使用されます。最初の要素には、常にprocess.execPathと同じ値が含まれます。 構文 process.argv() パラメータ node.jsプロセスの前に渡されたすべてのコマンドライン引数を返すため。ユーザーからの入力は必要ありません。 例 argv.jsという名前のファイルを作成し、以下のコードスニペットをコピーします。ファイルを作成したら、次のコマンドを使用して、以下の例に示すようにこのコードを実行します- node argv.js argv.js