본문 바로가기
NodeJS

SyntaxError: Cannot use import statement outside a module 에러

by 데브믹서 2023. 7. 18.

import mysql from "mysql2/promise";

위 구문 부분에서 에러가 발생했다고 나온다



해결법

위에서처럼 package.json 에서

"type": "module"

부분을 추가하니까 정상적으로 실행된다

'NodeJS' 카테고리의 다른 글

node pkg의 exe 생성 명령어  (0) 2022.11.08
NPM 이용시 "must use TLS 1.2 or higher" 메시지 해결  (0) 2022.08.20