我有一个在开发和生产中工作的typescript模块。它使用https://github.com/lorenwest/node-config,我正尝试将它导入jest来编写测试,并且它抛出一个错误,指示配置对象未定义
TypeError: Cannot read property 'get' of undefined
at Object.<anonymous> (src/email/email.service.ts:1877:43)从…
import config from 'config'
console.log('**********CONFIG GET*********', config); // undefined
const sendgridToken: string = config.get('socialApi.value') // throws error我希望config是定义的,它是config模块的默认导出
环境:
node-config version: config@3.2.4
node-version: 12.13.1
tsc -v
Version 3.7.4
ts-jest@24.3.0发布于 2020-01-16 16:38:35
而不是
import config from 'config'写这篇文章
import * as config from 'config'https://stackoverflow.com/questions/59756709
复制相似问题