【问题标题】:SyntaxError: Cannot use import statement outside a module using @ionic-native/health in Angular/Nx/jest appSyntaxError:无法在 Angular/Nx/jest 应用程序中使用 @ionic-native/health 的模块外部使用 import 语句
【发布时间】:2020-05-26 03:33:06
【问题描述】:

请帮忙,我明白了

SyntaxError: Cannot use import statement outside a module" 

在 Angular 应用程序中使用 @ionic-native/health。 repo 在这里,运行“npm i”,然后“ng test”:

https://github.com/chauey/import-issue-ws

【问题讨论】:

  • 请更新您的帖子:复制/粘贴(以文本形式)您引用“@ionic-native/health”的地方。我在 app.component.spec.ts 中没有看到它——看起来不错。问题是“ng test”以某种方式占用了 index.js,这导致了非法语法错误。

标签: angular jestjs ionic-native nrwl-nx


【解决方案1】:

相信我终于找到了答案:

jest.config.js

transformIgnorePatterns: ['node_modules/(?!@ngrx|@ionic-native|@ionic)']

tsconfig.spec.json

"allowJs": true

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-02
    • 1970-01-01
    • 2022-06-13
    • 1970-01-01
    • 2021-02-22
    • 2022-01-25
    • 2021-01-30
    • 2020-03-15
    相关资源
    最近更新 更多