找不到'@types'的类型定义文件

时间:2019-06-03 11:51:08

标签: ionic-framework

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

当我尝试使用命令'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

3 个答案:

答案 0 :(得分:5)

@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"
  }

答案 1 :(得分:2)

将@ ionic / app-scripts版本降级为3.2.3对我而言是可行的。

 npm i @ionic/app-scripts@3.2.3

答案 2 :(得分:0)

确保在package.json中使用最新版本的@ ionic / app-scripts。我遇到了此错误,并使用最新版本解决了该问题。