更新到 ionic-native 2.5.1 后的 ionic 2 Typescript 错误 TS1005
Posted
技术标签:
【中文标题】更新到 ionic-native 2.5.1 后的 ionic 2 Typescript 错误 TS1005【英文标题】:ionic 2 Typescript Error TS1005 after updated to ionic-native 2.5.1 【发布时间】:2017-07-16 21:13:20 【问题描述】:在我的 ionic 2 项目中更新到最新的 ionic-native (2.5.1) 后,我在终端中运行“ionic serve”时遇到 Typescript 错误。我试图将打字稿更新到 2.x 版,但仍然无法正常工作。请帮忙。
错误信息:
TypeScript error: ../ionic2/ionic2-angularfire-sample-master/node_modules/ionic-native/dist/es5/plugins/mixpanel.d.ts(74,21): Error TS1005: '=' expected.
TypeScript error: ../ionic2/ionic2-angularfire-sample-master/node_modules/ionic-native/dist/es5/plugins/mixpanel.d.ts(74,27): Error TS1005: ';' expected.
TypeScript error: ../ionic2/ionic2-angularfire-sample-master/node_modules/ionic-native/dist/es5/plugins/mixpanel.d.ts(74,29): Error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
TypeScript error: ../ionic2/ionic2-angularfire-sample-master/node_modules/ionic-native/dist/es5/plugins/mixpanel.d.ts(75,1): Error TS1128: Declaration or statement expected.
我的离子信息:
Your system information: Cordova CLI: 6.4.0 Ionic Framework Version: 2.0.0-beta.11 Ionic CLI Version: 2.1.1 Ionic App Lib Version: 2.1.1
我的 package.json:
"dependencies":
"@angular/common": "2.0.0-rc.4",
"@angular/compiler": "2.0.0-rc.4",
"@angular/core": "2.0.0-rc.4",
"@angular/forms": "0.2.0",
"@angular/http": "2.0.0-rc.4",
"@angular/platform-browser": "2.0.0-rc.4",
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
"@angular/router": "2.0.0-rc.2",
"@types/core-js": "^0.9.35",
"@types/lodash": "^4.14.53",
"angular": "^1.6.2",
"angularfire2": "2.0.0-beta.2",
"es6-shim": "0.35.0",
"firebase": "3.3.0",
"ionic-angular": "2.0.0-beta.11",
"ionic-native": "^2.5.1",
"ionicons": "3.0.0",
"moment": "2.13.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "0.6.12"
,
"devDependencies":
"@ionic/app-scripts": "^1.1.4",
"del": "2.2.0",
"gulp": "3.9.1",
"gulp-tsc": "^1.3.0",
"gulp-tslint": "^5.0.0",
"gulp-watch": "4.3.5",
"ionic-gulp-browserify-typescript": "^1.1.0",
"ionic-gulp-fonts-copy": "^1.0.0",
"ionic-gulp-html-copy": "^1.0.0",
"ionic-gulp-sass-build": "^1.0.0",
"ionic-gulp-scripts-copy": "^2.0.0",
"ionic-gulp-tslint": "^1.0.0",
"run-sequence": "1.1.5",
"tslint": "^3.10.1",
"tslint-ionic-rules": "^0.0.3",
"gulp-typescript": "^2.13.6",
"typescript": "^2.0.2",
"typings": "^2.1.0"
我在 tsc -v 中的 typescript 版本:
Version 2.2.1
请帮忙。谢谢!!!
【问题讨论】:
用这个 mixpanel.ts 文件更新您的帖子 【参考方案1】:我在这里看到了很多问题。
您的Ionic 框架处于测试阶段。
你应该这样做npm install -g ionic@latest
。
要获取 Ionic 项目的最新依赖项,您可以参考 package.json 以获取入门基础 here。这些是你做ionic start proj --v2 template_name
时下载的依赖。
注意:
甚至这个 package.json 指定 ionic-native 版本 2.4.1
和应用脚本为 1.1.3
而你的被提到更高。
【讨论】:
感谢您的回复。在我做了npm install -g ionic@latest
之后,又出现了Error: Cannot find module '@angular/tsc-wrapped/src/tsc'
的另一个问题。请帮忙。 @suraj
你检查过 package.json 吗?
你的意思是我需要把从新项目创建的新package.json放到我当前的项目中吗?
您可以这样做并添加您似乎拥有的所有其他依赖项并检查以上是关于更新到 ionic-native 2.5.1 后的 ionic 2 Typescript 错误 TS1005的主要内容,如果未能解决你的问题,请参考以下文章
离子服务无法获取/找不到模块'@ionic-native/splash-screen/ngx'
Ionic 2 - 导入 @ionic-native/geolocation 会导致构建失败
将 Cordova 插件与 IONIC 一起使用,而不是 ionic-native
ionic-native/http 发出错误“NullInjectorError: No provider for HTTP!”