본문 바로가기

JavaScript7

[Node.js / Error] return process.dlopen(module, path.toNamespacedPath(filename)); Node.js app.js 실행 시 Error return process.dlopen(module, path.toNamespacedPath(filename)); ==> node_modlues 버전이 안맞아서 발생하는 error. rm -rf node_modules npm update 기존의 node_modlues 폴더 삭제 후 업데이트, 그리고 실행하면 잘 된다. 참고 : https://velog.io/@howooke/%EB%B0%B0%ED%8F%AC%EC%8B%9C-%EC%97%90%EB%9F%ACreturn-process.dlopenmodule-path.toNamespacedPathfilename 2024. 4. 8.
[Javascript] variable 과 !!variable - Double Exclamation Mark const res = variable const booleanRes = !!variable - !! (Double Exclamation Mark) !!variable 만약 variable이 null, undefined, 0, 빈 문자열 등의 falsy한 값이라면 강제 Boolean 변환 후에는 true가 되고, 이를 다시 부정 연산자로 적용하면 false가 됩니다. if (variable) if (!!variable) - if (variable) 와 if (!!variable) JavaScript에서 조건문을 사용하여 변수 variable의 값이 존재하는지 여부를 확인하는 코드. if (variable): 이 코드는 변수 variable이 존재하는지 여부를 확인. JavaScript에서는 falsy한 값.. 2024. 3. 6.
[Javascript] throw Error 와 console.error 차이 throw Error("msg"); console.error("msg"); Some of the Differences are: throw Error("msg"): Stops js execution. (실행 중인 JavaScript를 중단시킵니다.) Mostly used for code handling purpose. (주로 코드 처리 목적으로 사용됩니다.) Can alter main flow of execution. (주 실행 흐름을 변경할 수 있습니다.) This syntax is mostly same for all browser as this is specified and validated by W3C. (이 구문은 W3C에서 지정되어 검증되므로 대부분의 브라우저에서 거의 동일합니다.) console.. 2024. 2. 28.
[Javascript] typeerror (intermediate value) is not iterable typeerror (intermediate value) is not iterable 배열을 반환하지 않는 경우 아래와 같이 변경. bracket 제거 const [result] = await db.query(`...`); ↓ const result = await db.query(`...`); 참고 : https://stackoverflow.com/questions/74626629/error-typeerror-intermediate-value-is-not-iterable-i 2024. 2. 28.
[Typescript] variable type 1. Variable Declaration in TypeScript - type number - type boolean - type any : 지양할 것. 변수 선언과 동시에 초기화할 경우 type 지정 안 해도 됨. type interface 생략해도 typescript 가 자동 감지 너무 명확할때는 type 명시 안 하는 게 좋다. type 안써줘도 type이 할당되어 type error가 발생. // number // let userId: number = 334455; let userId = 334455; userId.toFixed(); userId = 'hhhh'; // boolean let isLoggedIn: boolean = false; - any any 가 나오게 되는 경우를 지양하자. a.. 2024. 2. 7.
[Node.js] Error: error:0308010C:digital envelope routines::unsupported Error: error:0308010C:digital envelope routines::unsupported 주로 최신 버전의 node에서 생기는 이슈인 듯 하다.. 해결방법 터미널에서 아래 명령어 입력하기 export NODE_OPTIONS=--openssl-legacy-provider 참고 : https://github.com/webpack/webpack/issues/14532 2022. 10. 27.