我尝试使用离子和cordova构建运行app时,在节点模块中出现了几个错误。我在命令行上运行ionic cordova run androidcommand时遇到错误。我也尝试更新离子和角度到最新版本仍然显示我同样的错误。你能帮忙解决这个问题吗?以下是我的package.json文件。请看看。
[01:39:24] typescript: F:/Ionic apps/myApp/node_modules/@ionic/app-scripts/dist
/util/interfaces.d.ts, line: 1
Cannot find type definition file for 'node'.
L1: import { CompilerHost, CompilerOptions, Program } from 'typescript';
L2: import { FileCache } from './file-cache';
[01:39:24] typescript: F:/Ionic apps/myApp/node_modules/@ionic/app-scripts/dist
/util/interfaces.d.ts, line: 131
Cannot find name 'Buffer'.
L130: writeFile(filePath: string, fileContent: Buffer, callback: Function)
: void;
L131: mkdirp(filePath: string, callback: Function): void;
L132: mkdir(filePath: string, callback: Function): void;
Error: Failed to transpile program
at BuildError.Error (native)
at new BuildError (F:\Ionic apps\myApp\node_modules\@ionic\app-scripts\dist\
util\errors.js:16:28)
at F:\Ionic apps\myApp\node_modules\@ionic\app-scripts\dist\transpile.js:159
:20
at transpileWorker (F:\Ionic apps\myApp\node_modules\@ionic\app-scripts\dist
\transpile.js:107:12)
at Object.transpile (F:\Ionic apps\myApp\node_modules\@ionic\app-scripts\dis
t\transpile.js:64:12)
at F:\Ionic apps\myApp\node_modules\@ionic\app-scripts\dist\build.js:109:82
[01:39:25] copy finished in 14.86 s
F:\Ionic apps\myApp>

以下是我的package.json`
"name": "cricket",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/animations": "5.2.9",
"@angular/common": "5.2.9",
"@angular/compiler": "5.2.9",
"@angular/compiler-cli": "5.2.9",
"@angular/core": "5.2.9",
"@angular/forms": "5.2.9",
"@angular/http": "5.2.9",
"@angular/platform-browser": "5.2.9",
"@angular/platform-browser-dynamic": "5.2.9",
"@firebase/app": "^0.1.10",
"@ionic-native/core": "4.5.3",
"@ionic-native/splash-screen": "4.5.3",
"@ionic-native/status-bar": "4.5.3",
"@ionic/pro": "1.0.20",
"@ionic/storage": "^2.1.3",
"angularfire2": "^5.0.0-rc.6.0",
"cordova-android": "^6.3.0",
"cordova-plugin-device": "^2.0.1",
"cordova-plugin-firebase": "^0.1.25",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^1.2.0",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-sqlite-storage": "^2.3.0",
"firebase": "^4.13.1",
"ionic-angular": "3.9.2",
"ionicons": "3.0.0",
"path": "^0.12.7",
"rxjs": "5.5.7",
"sw-toolbox": "3.6.0",
"upstox": "^1.2.3",
"zone.js": "0.8.20"
},
"devDependencies": {
"@ionic/app-scripts": "^3.1.7",
"typescript": "~2.6.2"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-firebase": {},
"cordova-sqlite-storage": {},
"cordova-plugin-whitelist": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {}
}
}
}

`
答案 0 :(得分:0)
我通过检查来自Changelog Description的cordova-android和@ ionic / app-scripts兼容性解决了这个问题
1.安装cordova-android版本(6.4.0或6.3.0)和@ ionic / app-scripts版本(3.1.8)
2.删除android平台并添加它agian。