leeda-cloud

Cannot use import statement outside a module 에러 해결법 본문

에러

Cannot use import statement outside a module 에러 해결법

leeda-cloud 2023. 11. 8. 18:11

세팅 중 Cannot use import statement outside a module 라는 에러가 나왔다.

 

 import문을 사용할 수 없다는 건데, 이건 간단히 해결할 수 있다.

// package.json
{
  "type": "module"
}

그러고 다시 실행하면 멀쩡하게 돌아간다!

만약 위 방법이 안 통한다면 아래 참고 url에 들어가면 다양한 해결법이 있다.

 

참고 url : https://stackoverflow.com/questions/58384179/syntaxerror-cannot-use-import-statement-outside-a-module

 

SyntaxError: Cannot use import statement outside a module

I've got an ApolloServer project that's giving me trouble, so I thought I might update it and ran into issues when using the latest Babel. My "index.js" is: require('dotenv').config() imp...

stackoverflow.com

 

 

 

Comments