nodejs ERR_INVALID_ARG_TYPE 오류
예전에 문제 없던것인데 문제가 발생 합니다.
형변환을 하면 되는데 우선 간단하게 오래된 습관으로 + '' 해서 문자열로 만들어 주는 방법을 사용 해도 되는데요.
제가 발생한 부분은 아래와 같습니다.
숫자를 받아 들이지 않네요.!!
fs.writeFileSync(pid_file, process.pid + '', 'utf-8');
node:internal/errors:465
ErrorCaptureStackTrace(err);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (123)
at Object.writeFileSync (node:fs:2163:5)
at /www/main_lode.js:61:6
at Object.<anonymous> (/www/main_lode.js:245:3)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'ERR_INVALID_ARG_TYPE'
}