I have a typescript module that works in dev and production. it uses https://github.com/lorenwest/node-config I am trying to import it into jest to write tests against and it throws an error that indicates the config object is undefined
TypeError: Cannot read property 'get' of undefined
at Object.<anonymous> (src/email/email.service.ts:1877:43)
from
import config from 'config'
console.log('**********CONFIG GET*********', config); // undefined
const sendgridToken: string = config.get('socialApi.value') // throws error
I'd expect config to be defined its the default export of the config module
environment:
node-config version: config@3.2.4
node-version: 12.13.1
tsc -v
Version 3.7.4
ts-jest@24.3.0
instead of
import config from 'config'
write this
import * as config from 'config'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.