chalk/chalk

Chalk error, Cannot use import statement outside a module

masb0ymas opened this issue · 1 comments

Stack :

  • Node 16.18.0
  • Chalk 5.2.0
  • TypeScript 4.9.4
  • package.json ( type: commonjs )

error when I run the code. the code i wrote is like this, is there something wrong?

export function logServer(type: string, message: string): string {
  const newType = chalk.blue(type)
  const newMessage = chalk.green(message)

  const result = `[server]: ${newType} ${newMessage}`

  return result
}
SyntaxError: Cannot use import statement outside a module

    > 1 | import chalk from 'chalk'
        | ^
      2 | import _ from 'lodash'
      3 | import { validate as uuidValidate } from 'uuid'
      4 |