기주

[ERROR] ReferenceError: exports is not defined in ES module scope 본문

TIL

[ERROR] ReferenceError: exports is not defined in ES module scope

기주그지마 2024. 5. 28. 12:26

 

 

nest project를 실행할때 에러가 발생했다.

 

ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and 
'/Users/kiju/dev/study/crime-city/package.json' contains "type": "module". 
To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

 

 

 

 

package.json에  "type" : "module" 을 지웠더니 해결되었다

 

 

 

참고)

https://stackoverflow.com/questions/71321728/this-file-is-being-treated-as-an-es-module-because-it-has-a-js-file-extension