如何在没有TypeError的情况下执行ng-xi18n:无法读取undefined的属性'create'? [英] How to execute ng-xi18n without TypeError: Cannot read property 'create' of undefined?

查看:164
本文介绍了如何在没有TypeError的情况下执行ng-xi18n:无法读取undefined的属性'create'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想利用Angular 2的国际化(i18n)在我的Ionic 2项目中。遗憾的是,我无法使用ng-xi18n工具尝试以下命令创建翻译源文件:

I want to make use of the internationalization (i18n) of Angular 2 in my Ionic 2 project. Unfortunatly I can't create a translation source file with the ng-xi18n tool trying following command:

./node_modules/.bin/ng-xi18n

出现以下TypeError:

Following TypeError appears:

TypeError: Cannot read property 'create' of undefined
    at Function.Extractor.create (/Users/user/Development/app/node_modules/@angular/compiler-cli/src/extractor.js:69:45)
    at extract (/Users/user/Development/app/node_modules/@angular/compiler-cli/src/extract_i18n.js:7:34)
    at Object.main (/Users/user/Development/app/node_modules/@angular/tsc-wrapped/src/main.js:47:16)
    at Object.<anonymous> (/Users/user/Development/app/node_modules/@angular/compiler-cli/src/extract_i18n.js:14:9)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
Extraction failed

我尝试升级我的套餐但没有成功。这里我的依赖项在文件 package.json

I tried an upgrade of my packages without success. Here my dependencies in the file package.json

"dependencies": {
    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/compiler-cli": "^2.4.0",
    "@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/platform-server": "^2.4.0",
    "es6-shim": "0.35.1",
    "ionic-angular": "2.0.0-beta.11",
    "ionic-native": "1.3.10",
    "ionicons": "3.0.0",
    "reflect-metadata": "0.1.8",
    "rxjs": "5.0.0-beta.6",
    "typescript": "^2.1.4",
    "zone.js": "0.6.12"
},

过去也许有人解决了这个问题。感谢先进的答案。

Maybe someone has solved this issue in the past. Thanks for answers in advanced.

推荐答案

回答我自己的问题:这是依赖项的问题。重写 package.json 解决了这个问题。

To answer my own question: It was an issue with the dependencies. Rewriting the package.json solves this.

"dependencies": {
  "@angular/common": "2.2.1",
  "@angular/compiler": "2.2.1",
  "@angular/compiler-cli": "2.2.1",
  "@angular/core": "2.2.1",
  "@angular/forms": "2.2.1",
  "@angular/http": "2.2.1",
  "@angular/platform-browser": "2.2.1",
  "@angular/platform-browser-dynamic": "2.2.1",
  "@angular/platform-server": "2.2.1",
  "ionic-angular": "^2.0.0-rc.4",
  "ionic-native": "^2.2.12",
  "ionicons": "^3.0.0",
  "rxjs": "5.0.0-beta.12",
  "typescript": "^2.1.4",
  "zone.js": "^0.6.21"
},

也许只是短时间的解决方案,直到出现下一个错误。

Maybe only a solution for short time, until the next error appears.

这篇关于如何在没有TypeError的情况下执行ng-xi18n:无法读取undefined的属性'create'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆