기술공부/언어
[Node.js] jsonpath 패키지 사용 시 pkg build Error (Error: Cannot find module 'esprima' Require stack:- aesprim) 발생 해결 방법
봉두두
2024. 6. 25. 14:39
728x90
jsonpath 패키지를 설치하고 나서부터 pkg로 빌드한 exe가 실행이 안 되는 문제가 발생.
원인을 찾아보고자 애꿎은 Visual studio 2022도 재설치 해보고,,
[C++를 사용한 데스크톱 개발] 워크로드도 재설치 해보고..
어떤 StackOverflow 답변에서는 개별 설치에서 SDK for Windows 10도 체크 후 설치해야한다는 최신 댓글도 달렸길래 추가 설치도 해봤는데 해결될 조짐이 1도 안 보였다.
그러다가 발견한 아래 글..
I found a pretty good workaround for my use case. Instead of
require("jsonpath")
, use
require("jsonpath/jsonpath.min")
The latter is basically the browserified version, and that one doesn't use the monkey-patching trickery that breaks the Pkg build. Hope that's useful!
왜인지 모르겠지만 jsonpath가 아니라 jsonpath.min을 import해야 문제 없이 돌아간다네.
chatGPT도 원인은 절대 모르던데.....ㅎ 아무튼 답변 주신 분께 무한 감사를 드립니다...
References
https://github.com/dchester/jsonpath/issues/96#issuecomment-432199710
Support pkg (executable nodejs app) · Issue #96 · dchester/jsonpath
https://www.npmjs.com/package/pkg can't handle pathed aesprim module with error Error: Cannot find module 'esprima' At the moment I don't use @ literal in json paths so the dirty hack to make it wo...
github.com
728x90
728x90