【问题标题】:Cannot find type definition file for '@types'找不到“@types”的类型定义文件
【发布时间】:2019-06-03 11:51:08
【问题描述】:

所以我正在为 android 和 ios 设备构建一个 ionic 应用程序。

当我尝试使用命令 'ionic cordova build android --prod --release' 在 android 中构建应用程序时,它在(在 Windows 上)运行良好

在 ios 中使用相同的命令(在 mac 上)对接,给我这个错误:

10:35:55]  typescript error 
        Cannot find type definition file for '@types'. 

[10:35:55]  ionic-app-script task: "build" 
[10:35:55]  Error: Failed to transpile TypeScript 
Error: Failed to transpile TypeScript
at errorCheckProgram (/Users/zakaria/Desktop/untitled 
folder/transatour/node_modules/@ionic/app-scripts/dist/aot/aot- 
compiler.js:119:39)
at Object.<anonymous> (/Users/zakaria/Desktop/untitled 
folder/transatour/node_modules/@ionic/app-scripts/dist/aot/aot- 
compiler.js:89:21)
at step (/Users/zakaria/Desktop/untitled 
folder/transatour/node_modules/@ionic/app-scripts/dist/aot/aot- 
compiler.js:32:23)
at Object.next (/Users/zakaria/Desktop/untitled 
folder/transatour/node_modules/@ionic/app-scripts/dist/aot/aot- 
compiler.js:13:53)
at fulfilled (/Users/zakaria/Desktop/untitled 
folder/transatour/node_modules/@ionic/app-scripts/dist/aot/aot- 
compiler.js:4:58)
[ERROR] An error occurred while running subprocess ionic-app- 
scripts.

    ionic-app-scripts build --prod --target cordova --platform ios 
 exited with exit code 1.

    Re-running this command with the --verbose flag may provide 
more information.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! transatour@0.0.1 build:prod:ios: `cross-env 
NODE_OPTIONS='- 
-max-old-space-size=8192' ionic cordova build ios --prod --release`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the transatour@0.0.1 build:prod:ios script.
npm ERR! This is probably not a problem with npm. There is likely 
additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/zakaria/.npm/_logs/2019-06-03T11_35_55_786Z- 
 debug.log

【问题讨论】:

  • 我可以知道您的 app-scripts 版本在 package.json 文件中吗?
  • "@ionic/app-scripts": "^3.2.3"
  • 好的,所以只需删除^ 意味着在3.2.3 上冻结您的应用脚本版本将解决您的问题。
  • 还是同样的问题
  • 以上更改后你运行npm install了吗?

标签: json typescript ionic-framework


【解决方案1】:

@ionic/app-scripts: 3.2.3 升级到最新版本 3.2.4 后出现此错误。

我没有降级来修复它

我加了

"types": [],

进入

"compilerOptions"

tsconfig.json 文件中,错误消失了。

现在我的tsconfig.json 文件如下所示:

"compilerOptions": {
    "types": [],  <== fix added here <==
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5"
  }

【讨论】:

  • 我得到了Cannot find type definition file for 'node',我像你一样清空了类型数组,现在它工作正常
  • 遇到了同样的问题。解决方案对我有用..谢谢。
【解决方案2】:

将@ionic/app-scripts 版本降级到 3.2.3 对我有用。

 npm i @ionic/app-scripts@3.2.3

【讨论】:

    【解决方案3】:

    确保您在 package.json 中使用最新版本的 @ionic/app-scripts。我遇到了这个错误,升级到最新版本解决了它。

    【讨论】:

      猜你喜欢
      • 2019-10-11
      • 2018-06-05
      • 2018-07-20
      • 2021-08-15
      • 2017-06-18
      • 2018-07-31
      • 2019-01-03
      • 2022-11-03
      • 2019-05-15
      相关资源
      最近更新 更多