* /usr/ET/project/zktWeb/test.js
// cd ~
// node /usr/ET/project/zktWeb/test.js
// 当前执行node的路径 e.g. /usr/local/node/10.16.0/bin/node
console.log("process.execPath=" + process.execPath);
// 代码test.js所在的路径
console.log("_dirname=" + __dirname);
// 当前命令行的路径
console.log("process.cwd()=" + process.cwd());
cd ~
node /usr/ET/project/zktWeb/test.js
cd -
输出结果:
process.execPath=/home/ubuntu/.nvm/versions/node/v8.11.2/bin/node
_dirname=/usr/ET/project/zktWeb
process.cwd()=/home/ubuntu