- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在使用 angular2。
我用了this project开始申请。
要实现多语言支持,请遵循 this documentation
步骤:1)执行命令
npm install @angular/compiler-cli @angular/platform-server --save
输出:
+-- UNMET PEER DEPENDENCY rxjs@5.0.0-rc.5 `-- UNMET PEER DEPENDENCY tslint@4.0.2
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.15: wanted {"os":"darwin","arch" :"any"} (current: {"os":"win32","arch":"x64"}) npm WARN @angular/core@2.1.1 requires a peer of rxjs@5.0.0-beta.12 but none was installed. npm WARN @angular/forms@2.2.4 requires a peer of @angular/core@2.2.4 but none was installed. npm WARN @angular/forms@2.2.4 requires a peer of @angular/common@2.2.4 but none was installed. npm WARN @angular/http@2.1.1 requires a peer of rxjs@5.0.0-beta.12 but none was installed. npm WARN @angular/router@3.1.1 requires a peer of rxjs@5.0.0-beta.12 but none was installed. npm WARN codelyzer@1.0.0-beta.4 requires a peer of tslint@^3.9.0 but none was installed. npm WARN codelyzer@1.0.0-beta.4 requires a peer of @angular/compiler@~2.2.0 but none was installed. npm WARN codelyzer@1.0.0-beta.4 requires a peer of @angular/core@~2.2.0 but none was installed. npm WARN tslint-loader@2.1.5 requires a peer of tslint@^3.0.0 but none was installed. npm WARN @angular/compiler-cli@2.4.1 requires a peer of @angular/compiler@2.4.1 but none was installed. npm WARN @angular/compiler-cli@2.4.1 requires a peer of @angular/core@2.4.1 but none was installed.
2) 执行命令“./node_modules/.bin/ng-xi18n” 它给了我以下错误
C:\Projects\temp\PathTrak3\PathTrak>"./node_modules/.bin/ng-xi18n" TypeError: Cannot read property 'create' of undefined at Function.Extractor.create (C:\Projects\temp\PathTrak3\PathTrak\node_modules\@angular\compiler-cli\src\extractor .js:69:45) at extract (C:\Projects\temp\PathTrak3\PathTrak\node_modules\@angular\compiler-cli\src\extract_i18n.js:7:34) at Object.main (C:\Projects\temp\PathTrak3\PathTrak\node_modules\@angular\tsc-wrapped\src\main.js:47:16) at Object. (C:\Projects\temp\PathTrak3\PathTrak\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 文件中找到以下依赖项
"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 如下,解决了 UNMET 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
package.json 文件
"dependencies": {
"@angular/common": "~2.4.1",
"@angular/compiler": "~2.4.1",
"@angular/compiler-cli": "~2.4.1",
"@angular/core": "~2.4.1",
"@angular/forms": "~2.4.1",
"@angular/http": "~2.4.1",
"@angular/platform-browser": "~2.4.1",
"@angular/platform-browser-dynamic": "~2.4.1",
"@angular/platform-server": "~2.4.1",
"@angular/router": "~3.4.1",
"@angularclass/conventions-loader": "^1.0.2",
"@angularclass/hmr": "~1.2.2",
"@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.2",
"zone.js": "~0.7.4"
},
"devDependencies": {
"@types/hammerjs": "^2.0.33",
"@types/jasmine": "^2.2.34",
"@types/node": "^6.0.38",
"@types/protractor": "^1.5.20",
"@types/selenium-webdriver": "2.53.38",
"@types/source-map": "^0.5.0",
"@types/uglify-js": "^2.0.27",
"@types/webpack": "^2.0.0",
"angular2-template-loader": "^0.6.0",
"awesome-typescript-loader": "~3.0.0-beta.17",
"codelyzer": "~2.0.0-beta.4",
"copy-webpack-plugin": "^4.0.0",
"css-loader": "^0.26.0",
"exports-loader": "^0.6.3",
"expose-loader": "^0.7.1",
"file-loader": "^0.9.0",
"gh-pages": "^0.12.0",
"html-webpack-plugin": "^2.21.0",
"imports-loader": "^0.7.0",
"istanbul-instrumenter-loader": "1.2.0",
"json-loader": "^0.5.4",
"karma": "^1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-mocha-reporter": "^2.0.0",
"karma-remap-coverage": "^0.1.4",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "1.8.1",
"node-sass": "^4.1.1",
"parse5": "^2.2.1",
"protractor": "^4.0.10",
"raw-loader": "0.5.1",
"rimraf": "~2.5.4",
"sass-loader": "^4.1.1",
"script-ext-html-webpack-plugin": "1.3.2",
"source-map-loader": "^0.1.5",
"string-replace-loader": "1.0.5",
"style-loader": "^0.13.1",
"to-string-loader": "^1.1.4",
"ts-helpers": "1.1.2",
"ts-node": "^2.0.0",
"tslint": "^4.0.0-dev.0",
"tslint-loader": "^3.3.0",
"typedoc": "^0.5.3",
"typescript": "2.0.10",
"url-loader": "^0.5.7",
"webpack": "^2.1.0-beta",
"webpack-dev-middleware": "^1.6.1",
"webpack-dev-server": "2.2.0-rc.0",
"webpack-md5-hash": "^0.0.5",
"webpack-merge": "~2.0.0"
}
最佳答案
我想这只是您的angular 版本 不匹配。您应该为每个 @angular
坚持使用相同的版本包(路由器除外,它将高出 1 个主要版本直到发布 angular 4)。
与你的...
npm install @angular/compiler-cli @angular/platform-server --save
...看起来你至少有@angular/compiler-cli
在 2.4.1 并且可能和 @angular/platform-server
在 2.4.1。因为你设置了other @angular
打包到固定版本 2.1.1 会有一些冲突。
注意:文档将始终假定您使用的是最新(稳定)的 Angular 版本。
那么如何解决呢...
您可以通过添加 @angular/compiler-cli
来安装旧包& @angular/platform-server
修复 package.json
中的 2.1.1 (不要忘记在此处删除插入符号 (^))。然后删除你的 node_modules
文件夹并运行 npm install
再次。
另一种选择是更新您的其他 @angular
包也更新到最新的 2.4.1 版本。在这里,您必须将 package.json
中的 2.1.1 替换为 2.4.1 (除了 3.4.1 的路由器)。然后删除你的 node_modules
文件夹并运行 npm install
再次。
在这里您可能会遇到一些其他问题,具体取决于您的应用...您可能需要检查 Changelog首先。
仅供引用:当您安装新的 @angular
时打包到您的项目中,请始终坚持使用您现在使用的版本。要在您的情况下安装特定版本(请注意 @2.1.1
):
npm install @angular/compiler-cli@2.1.1 @angular/platform-server@2.1.1 --save
...或全部更新到新版本 ;-)
关于angular2 i18n 无法读取未定义的属性 'create',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41362551/
假设有一个创建用户的操作。如果存在指定的电子邮件或用户名,此操作可能会失败。如果它失败了,则需要确切地知道原因。在我看来,有三种方法可以做到这一点,我想知道是否有明显的赢家。 所以,这是一个类用户:
var obj1 = Object.create; console.log(typeof obj1); var obj2 = Object.create(null); console.log(type
I am getting this error after running npm run build yield User.create({^在运行NPM Run Build Year Use
我应该为其他人将从中继承的第一个父对象传递哪个参数,哪个参数更有效 Object.create(Object.prototype) Object.create(Object) Object.creat
我正在尝试使用 JDBC(最新版本)设置 SQL Server 2008 数据库。 我有一个我想一起执行的 setup sql 命令列表: 基本上我做的是: connection.setAutoCom
我正在尝试创建一个 CloudFormation 模板来创建一个 Auto Scaling 组,以便我可以从中启动 2 个实例。 我已经创建了 Auto Scaling 组,但我不知道如何编写用于从
我正在创建我的第一个WordPress网站。我已经在我的网站上安装了Elementor Pro插件。随之而来的一个有利因素是“循环旋转木马”。。。当我把它添加到我的页面时,一切似乎都在工作,但是当我点
create-react-app error 我从终端运行yarn start时收到此错误消息...我尝试了sudo killall node和许多其他过程来清除i-node却没有成功。 我也将我的c
在 CRM 中,当我尝试设置工作流程时,我可以选择与某个实体的创建时间相关的超时。涉及三个字段。 记录创建于 创建于 修改时间 虽然最后一个很明显,但我看不出其他两个之间有任何逻辑上的区别。 最佳答案
我在一次采访中被问到这个问题。我无法回答。 "browserslist": [ ">0.2%", "not dead", "not ie <= 11", "not op_mini all" ] 我可以
这是一个 Rails 新手问题: 当我在模型上调用 create() 时,它会绕过关联的 Controller create 操作吗? 例如,这没有命中我的标签 Controller #create
我不明白这两种特权之间的区别。 我找到了这两种解释,但对我没有帮助。 CREATE TABLE -> Enables a user to create a table owned by that us
我是 SharePoint 工作流的新手。 创建新任务并分配 TaskId 时,我有两个选项: 创建一个新字段来保存 TaskId 创建一个新属性来保存 TaskId。 新属性是一个依赖属性。 我的问
我突然注意到我们的代码库中有一个TDataModuleTestExchange(nil)“构造函数调用”: procedure TDialoogConfigExchange.ButtonTestCli
我有一个具有 TComponent 变量的单元,我在单元初始化时创建此组件,如下所示: var XComp: TComponent; . . . . initialization begin
Composer 是否提供了更新项目创建时使用的包的方法?即,如果我使用以下内容创建一个新的 Laravel 项目 composer create-project --prefer-dist lara
在 Hibernate 中,如果我们将 hbm2ddl.auto 设置为 create/create-drop ,那么它将在启动时删除旧模式并创建新模式。这意味着,它也会删除数据?..我的疑问是,如果
我使用了 create an Automated Build 中的此链接 ( this guide ) . 浏览器错误控制台显示: https://hub.docker.com/v2/reposito
我已经搜索了 msdn 并没有找到答案。我应该知道有什么区别吗? 如果真的没有区别,那么为什么会存在这种冗余? --SQL Server Stored Procedure Syntax CREATE
我有以下内容: var CardViewModel = function (data) { ko.mapping.fromJS(data, {}, this); this.editin
我是一名优秀的程序员,十分优秀!