-
[NodeJS] Error [ERR_REQUIRE_ESM]: require() of ES Module ~ from ~ not supported. 에러언어/Javascript 2023. 8. 23. 17:29
npm run start:dev 로 서버를 구동시키면 잘 돌아가는게,
갑자기 아래의 에러를 뱉으면서 오류가 발생했다.
require() of ES Module C:\경로\node_modules\wrap-ansi\index.js from C:경로\node_modules\inquirer\lib\utils\screen-manager.js not supported.
Instead change the require of index.js in \screen-manager.js to a dynamic import() which is available in all CommonJS modules.해당 경로를 찾아보니 import가 아닌 require()로 모듈을 불러와서 나는 문제인것같았다.
이걸 언제 다 require() 로 바꾸는가..
package.json에다 "type":"module"을 추가해줘도 문제가 해결되지 않았다.
찾아보니 종종 버그가 발생하는 것 같다.
위 경로를 보면 wrap-ansi 모듈에서 나는 에러이다.
그래서 해당 패키지를 unistall 한 뒤 다시 install 하니 잘 작동한다.
특정 ES Module에서 에러가 난다면 해당 모듈을 삭제-재설치 하면 대부분 해결되는듯.
그리고 나의경우 "type":"module"은 제거해줘야 정상적으로 작동한다.
반응형'언어 > Javascript' 카테고리의 다른 글
POST : Cannot read properties of undefined (reading 'length') (0) 2023.08.30 update하면서 마주했던 에러 몇 가지 (0) 2023.08.24 typeorm repository.delete 삭제 안될 때 (0) 2023.08.22 Argument of type '{ a: A; }' is not assignable to parameter of type 'DeepPartial<"entity">[]'. (0) 2023.08.17 [NestJS] 네스트 JS Controller 데코레이터 정리 (0) 2023.08.16