angular2 i18n无法读取属性';创建';未定义的
我正在使用angular2。angular2 i18n无法读取属性';创建';未定义的,angular,internationalization,package.json,Angular,Internationalization,Package.json,我正在使用angular2。 我用过启动应用程序 实现多语言支持 步骤: 1) 执行命令 npm install @angular/compiler-cli @angular/platform-server --save 输出: +--未满足的对等依赖rxjs@5.0.0-rc.5`--未满足的对等依赖tslint@4.0.2 npm警告可选跳过可选依赖项:fsevents@^1.0.0 (节点\u模块\chokidar\节点\u模块\fsevents):npm WARN notsup 跳过可
我用过启动应用程序 实现多语言支持 步骤: 1) 执行命令
npm install @angular/compiler-cli @angular/platform-server --save
输出:
+--未满足的对等依赖rxjs@5.0.0-rc.5`--未满足的对等依赖tslint@4.0.2
npm警告可选跳过可选依赖项:fsevents@^1.0.0
(节点\u模块\chokidar\节点\u模块\fsevents):npm WARN notsup
跳过可选依赖项:不支持的平台
fsevents@1.0.15:通缉{“os”:“达尔文”,“拱门”:“任何”}(当前:
{“os”:“win32”,“arch”:“x64”})npm WARN@ANGUAL/core@2.1.1需要一个
同辈rxjs@5.0.0-beta.12,但没有安装。npm警告
@棱角的/forms@2.2.4需要@angular的对等方/core@2.2.4但是没有
已安装。npm警告@角度/forms@2.2.4需要一个同龄人
@棱角的/common@2.2.4但没有安装。npm警告
@棱角的/http@2.1.1需要一个同龄人rxjs@5.0.0-beta.12但没有一个是
安装。npm警告@角度/router@3.1.1需要一个同龄人
rxjs@5.0.0-beta.12,但没有安装。npm警告
codelyzer@1.0.0-beta.4需要tslint@^3.9.0的对等版本,但没有一个是
安装。npm警告codelyzer@1.0.0-beta.4需要一个
@angular/compiler@~2.2.0,但未安装。npm警告
codelyzer@1.0.0-beta.4需要一个@angular/core@~2.2.0的对等节点,但
没有安装。npm警告tslint-loader@2.1.5需要一个同龄人
tslint@^3.0.0,但未安装。npm警告
@角度/编译器-cli@2.4.1需要@angular的对等方/compiler@2.4.1
但没有安装。npm警告@角度/编译器-cli@2.4.1要求
棱角分明的同龄人/core@2.4.1但没有安装
2) 执行命令“/node_modules/.bin/ng-xi18n”
这给了我以下的错误
C:\Projects\temp\PathTrak3\PathTrak>“/node\u modules/.bin/ng-xi18n”
TypeError:无法读取未定义的属性“create”
在Function.Extractor.create(C:\Projects\temp\PathTrak3\PathTrak\node\u modules\@angular\compiler cli\src\Extractor
.js:69:45)
提取时(C:\Projects\temp\PathTrak3\PathTrak\node\u modules\@angular\compiler cli\src\extract\u i18n.js:7:34)
在Object.main(C:\Projects\temp\PathTrak3\PathTrak\node\u modules\@angular\tsc wrapped\src\main.js:47:16)
反对。(C:\Projects\temp\PathTrak3\PathTrak\node\u modules\@angular\compiler cli\src\extract\u i18n.js:
14:9)
在模块处编译(Module.js:570:32)
在Object.Module.\u extensions..js(Module.js:579:10)
在Module.load(Module.js:487:32)
在tryModuleLoad时(module.js:446:12)
在Function.Module.\u加载(Module.js:438:3)
在Module.runMain(Module.js:604:10)提取失败
由于此错误,我无法执行i18n。
请在package.json文件中找到以下依赖项
"dependencies": {
"@angular/common": "2.1.1",
"@angular/compiler": "2.1.1",
"@angular/compiler-cli": "^2.4.1",
"@angular/core": "2.1.1",
"@angular/forms": "^2.1.1",
"@angular/http": "2.1.1",
"@angular/platform-browser": "2.1.1",
"@angular/platform-browser-dynamic": "2.1.1",
"@angular/platform-server": "^2.1.1",
"@angular/router": "3.1.1",
"@angularclass/conventions-loader": "^1.0.2",
"@angularclass/hmr": "~1.2.0",
"@angularclass/hmr-loader": "~3.0.2",
"angular2-highcharts": "^0.4.0",
"assets-webpack-plugin": "^3.4.0",
"core-js": "^2.4.1",
"http-server": "^0.9.0",
"ie-shim": "^0.1.0",
"rxjs": "^5.0.0-rc.1",
"zone.js": "~0.6.17"
}
package.json文件中是否存在版本问题?
好心帮忙
谢谢,
萨达尔·纳勒
-------------------------------------修改-----------------
我删除了node_modules文件夹,并尝试更新package.json,如下所示,未满足的dpendancy问题得到解决,但在运行时出现如下错误
错误
C:\Projects\temp\PathTrak12\PathTrak>npm start
> angular2-webpack-starter@5.1.1 start C:\Projects\temp\PathTrak12\PathTrak
> npm run server:dev
> angular2-webpack-starter@5.1.1 server:dev C:\Projects\temp\PathTrak12\PathTrak
> webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/
keywords if/then/else require v5 option
C:\Projects\temp\PathTrak12\PathTrak\config\webpack.common.js:178
new ForkCheckerPlugin(),
^
TypeError: ForkCheckerPlugin is not a constructor
at module.exports (C:\Projects\temp\PathTrak12\PathTrak\config\webpack.common.js:178:7)
at Object.<anonymous> (C:\Projects\temp\PathTrak12\PathTrak\config\webpack.dev.js:23:31)
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.require (module.js:497:17)
at require (internal/module.js:20:19)
at requireConfig (C:\Projects\temp\PathTrak12\PathTrak\node_modules\webpack\bin\convert-argv.js:98:18)
at C:\Projects\temp\PathTrak12\PathTrak\node_modules\webpack\bin\convert-argv.js:111:17
at Array.forEach (native)
at module.exports (C:\Projects\temp\PathTrak12\PathTrak\node_modules\webpack\bin\convert-argv.js:109:15)
at Object.<anonymous> (C:\Projects\temp\PathTrak12\PathTrak\node_modules\webpack-dev-server\bin\webpack-dev-server.js:190:48)
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)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "server:de
v"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! angular2-webpack-starter@5.1.1 server:dev: `webpack-dev-server --config config/webpack.dev.js --progress --profile --watch
--content-base src/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular2-webpack-starter@5.1.1 server:dev script 'webpack-dev-server --config config/webpack.dev.js --progres
s --profile --watch --content-base src/'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular2-webpack-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs angular2-webpack-starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls angular2-webpack-starter
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Projects\temp\PathTrak12\PathTrak\npm-debug.log
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! angular2-webpack-starter@5.1.1 start: `npm run server:dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular2-webpack-starter@5.1.1 start script 'npm run server:dev'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular2-webpack-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run server:dev
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs angular2-webpack-starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls angular2-webpack-starter
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Projects\temp\PathTrak12\PathTrak\npm-debug.log
我想这只是你的角度版本不匹配。对于每个
@angular
软件包,您应该坚持使用相同的版本(除了路由器,在angular 4发布之前,它将是一个更高的主版本)
用你的
npm install @angular/compiler-cli @angular/platform-server --save
。。。看来您至少在2.4.1版上安装了@angular/compiler cli
,可能在2.4.1版上安装了@angular/platform server
。由于您已将其他@angular
软件包设置为2的固定版本。1.1将存在一些冲突
注意:文档将始终假定您使用的是最新(稳定)的Angle版本
那么如何修复它
1.安装旧软件包 您只需将
@angular/compiler cli
&@angular/platform server
添加到包.json中的fixed2.1.1(不要忘了在此处删除插入符号(^))。然后删除您的node\u modules
文件夹并再次运行npm install
2.或者更新其他包
另一个选项是将其他@angular
软件包也更新到最新的2.4.1版本。在这里,您必须用包.json中的2.4.1替换2.1.1(除了3.4.1路由器)。
然后删除您的node\u modules
文件夹并再次运行npm install
在这里,您可能会遇到一些其他问题,具体取决于您的应用程序。。。您可能需要检查第一个
仅供参考:在项目中安装新的@angular
软件包时,请始终坚持使用当前使用的版本。要在您的案例中安装特定版本,它应该是(注意@2.1.1
):
…或将所有更新到新版本;-) 也许这可以帮助你们:你们能检查一下有问题的修改部分吗。我已经删除了node_modules文件夹,更新了package.json并完成了npm安装。在运行时,它给了我一个错误。请提供帮助。关于您更新的错误,问题似乎是您正在使用3.x.x上的awesome typescript loader
包,看起来他们删除了其中的ForkCheckerPlugin
(请参见票证)。因此,你必须修改你的网页配置。我的印象是,你可能会更好地使用你的项目。看一看,这可能会让你省去一些头痛:-)
npm install @angular/compiler-cli @angular/platform-server --save
npm install @angular/compiler-cli@2.1.1 @angular/platform-server@2.1.1 --save