加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular2 i18n无法读取undefined属性’create’

发布时间:2020-12-17 10:23:54 所属栏目:安全 来源:网络整理
导读:我正在使用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 DEPE
我正在使用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_moduleschokidarnode_modulesfsevents): 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:ProjectstempPathTrak3PathTrak>”./node_modules/.bin/ng-xi18n”
TypeError: Cannot read property ‘create’ of undefined
at Function.Extractor.create (C:ProjectstempPathTrak3PathTraknode_modules@angularcompiler-clisrcextractor
.js:69:45)
at extract (C:ProjectstempPathTrak3PathTraknode_modules@angularcompiler-clisrcextract_i18n.js:7:34)
at Object.main (C:ProjectstempPathTrak3PathTraknode_modules@angulartsc-wrappedsrcmain.js:47:16)
at Object. (C:ProjectstempPathTrak3PathTraknode_modules@angularcompiler-clisrcextract_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

由于这个错误,我无法实现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文件中的版本问题吗?
请帮助

谢谢,
Sardar Nale

– – – – – – – – – – – – – – – – – – -修改 – – – – – – ——–

我删除了node_modules文件夹,并尝试更新package.json,如下所示,UNMET dpendancy问题已解决,但在运行时出现错误,
错误

C:ProjectstempPathTrak12PathTrak>npm start

> angular2-webpack-starter@5.1.1 start C:ProjectstempPathTrak12PathTrak
> npm run server:dev


> angular2-webpack-starter@5.1.1 server:dev C:ProjectstempPathTrak12PathTrak
> webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/

keywords if/then/else require v5 option

C:ProjectstempPathTrak12PathTrakconfigwebpack.common.js:178
      new ForkCheckerPlugin(),^
TypeError: ForkCheckerPlugin is not a constructor
    at module.exports (C:ProjectstempPathTrak12PathTrakconfigwebpack.common.js:178:7)
    at Object.<anonymous> (C:ProjectstempPathTrak12PathTrakconfigwebpack.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:ProjectstempPathTrak12PathTraknode_moduleswebpackbinconvert-argv.js:98:18)
    at C:ProjectstempPathTrak12PathTraknode_moduleswebpackbinconvert-argv.js:111:17
    at Array.forEach (native)
    at module.exports (C:ProjectstempPathTrak12PathTraknode_moduleswebpackbinconvert-argv.js:109:15)
    at Object.<anonymous> (C:ProjectstempPathTrak12PathTraknode_moduleswebpack-dev-serverbinwebpack-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 Filesnodejsnode.exe" "C:Program Filesnodejsnode_modulesnpmbinnpm-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:ProjectstempPathTrak12PathTraknpm-debug.log

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:Program Filesnodejsnode.exe" "C:Program Filesnodejsnode_modulesnpmbinnpm-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,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:ProjectstempPathTrak12PathTraknpm-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/hmr": "~1.2.2","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软件包坚持使用相同的版本(路由器除外,它将是1个主要版本,直到角度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的固定版本,因此会出现一些冲突.

注意:文档将始终假设您使用最新(稳定)角度版本.

那么如何解决它……

1.安装旧包装

您可以通过添加@ angular / compiler-cli& amp;来安装旧软件包. @ angular / platform-server修复你的package.json中的2.1.1(不要忘记在这里删除插入符号(^)).然后删除node_modules文件夹并再次运行npm install.

2. …或更新其他包

另一个选择是您将其他@ angular软件包更新到最新的2.4.1版本.在这里你必须用你的package.json中的2.4.1替换2.1.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

…或更新所有新版本;-)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读