首页 > 解决方案 > Angular 10 typescript 3.9 npm 运行测试在导入时失败

问题描述

我正在使用 Angular v10.0.3 和 typescript v 3.9.7。当我跑步时,npm run test:ci我得到以下信息。我import moment from 'moment'在我的组件和服务中使用。还在我的 tsconfig.app.json 中启用了“allowSyntheticDefaultImports”标志

"compilerOptions": {
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,  
}

任何人都可以帮助解决此错误吗?

export = moment;
        ~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag. 
client/app/shared/services/util.service.ts:3:8 - error TS1259: Module '"E:/Dev/TPS-Web/Src/OPUS/node_modules/moment/ts3.1-typings/moment"' can only be default-imported using the 'allowSyntheticDefaultImports' flag

谢谢

标签: angular10typescript3.8

解决方案


推荐阅读