Search code examples
typescriptrollup

Module '"./config"' has no exported member 'app_name'


Rediscover

config/index.ts

export default {
  app_name: 'app name'
}

index.ts

import { app_name } from './config/index'

error:

semantic error TS2305 Module '"./config"' has no exported member 'app_name'.

My question

Current solution:

export const app_name = 'app_name'

What is the problem?


Solution

  • When using export default, you can use import Whatever from "./config"; to import the module - so without the curly braces.

    You can only have 1 default export per module, and any other export is a named export, importable with the curly braces format.

    So, as the TS error states, you indeed have no named export called app_name