Angular2 i18n Unable to read 'create' property from undefined

I am using angular2.
I used this project to run the application.

To implement multi-language support, follow this documentation.

Steps: 1) Run the command

npm install @angular/compiler-cli @angular/platform-server --save 

Output:

+ - INDEPENDENT INDEPENDENCE OF INDEPENDENCE rxjs@5.0.0-rc.5 `- INDEPENDENCE OF INDEPENDENCE OF THE TERM tslint@4.0.2

npm WARN optionally SKIP ADDITIONAL DEPENDENCE: fsevents@ ^ 1.0.0 (node_modules \ chokidar \ node_modules \ fsevents): npm WARN notsup ADDITIONAL DEPENDENCE OF SKIP: Unsupported platform for fsevents@1.0.15 : wanted {"os", "d "arch": "any"} (current: {"os": "win32", "arch": "x64"}) npm WARN @ angular / core@2.1.1 requires equal rxjs@5.0.0-beta.12 , but none of them has not been installed. npm WARN @ angular / forms@2.2.4 requires a peer @ angular / core@2.2.4 , but none have been installed. npm WARN @ angular / forms@2.2.4 requires that @ angular / common@2.2.4 , but none have been installed. npm WARN @ angular / http@2.1.1 requires equal rxjs@5.0.0-beta.12 , but none have been installed. npm WARN @ angular / router@3.1.1 requires rxjs@5.0.0-beta.12 , but none have been installed. npm WARN codelyzer@1.0.0-b.4 requires a peer tslint@ ^ 3.9.0, but none have been installed. npm WARN codelyzer@1.0.0-b.4 requires @ angular / compiler@ ~ 2.2.0, but none of them have been installed. npm WARN codelyzer@1.0.0-b.4 requires a peer-to-peer connection @ angular / core@ ~ 2.2.0, but not one has been installed. npm WARN tslint-loader@2.1.5 requires tslint@ ^ 3.0.0, but none have been installed. npm WARN @ angular / compiler-cli@2.4.1 requires a peer-to-peer connection @ angular / compiler@2.4.1 but no one has been installed. npm WARN @ angular / compiler-cli@2.4.1 requires a peer @ angular / core@2.4.1 , but none have been installed.

2) Run the command "./node_modules/.bin/ng-xi18n" This gives me the error below

C: \ Projects \ Temp \ PathTrak3 \ PathTrak> "./ node_modules / bin / ng-xi18n" TypeError: Unable to read the "create" property from undefined in Function.Extractor.create (C: \ Projects \ temp \ PathTrak3 \ PathTrak \ node_modules \ @angular \ compiler-cli \ src \ extractor.js: 69: 45) when fetching (C: \ Projects \ temp \ PathTrak3 \ PathTrak \ node_modules \ @angular \ compiler-cli \ src \ extract_i18n.js: 7: 34) in Object.main (C: \ Projects \ temp \ PathTrak3 \ PathTrak \ node_modules \ @angular \ tsc-wrapped \ src \ main.js: 47: 16) in the object. (C: \ Projects \ Temp \ PathTrak3 \ PathTrak \ node_modules \ @angular \ Kli compiler \ SRC \ extract_i18n.js: 14: 9) on Module._compile (module.js: 570: 32) in Object.Module._extensions ..js (module.js: 579: 10) on Module.load (module.js: 487: 32) in tryModuleLoad (module.js: 446: 12) in Function.Module._load (module.js: 438: 3 ) on Module.runMain (module.js: 604: 10) Failed to retrieve

I cannot rule out i18n due to this error. Below are the dependencies in the package.json file

  "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" } 

Is this a version issue in the package.json file? Request for help

Thank you Sardar Nal

------------------------------------- Modification ------ ------ --------

I deleted the node_modules folder and tried to update package.json as follows, the UNMET dpendancy problem was solved, but during operation it gives an error as Error

 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 file

 "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" } 
+5
source share
1 answer

I assume this is just a mismatch in the angular versions . You must stick to the same version for every @angular package (except for the router, this will be 1 major version above until angular 4 is released).

With your...

 npm install @angular/compiler-cli @angular/platform-server --save 

... it looks like you have at least @angular/compiler-cli in 2. 4.1 and possibly @angular/platform-server in 2.4.1. Since you installed other @angular packages in the fixed version 2. 1.1 , some conflicts will arise.

Note. Documents will always assume that you are on the latest (stable) version of angular.

So how to fix it ...


1. installation of old packages

You can simply install the old packages by adding @angular/compiler-cli and @angular/platform-server to the fixed 2.1.1 in package.json (don't forget to remove the caret (^) here), then delete the node_modules folder and run npm install again .


2 .... or updating other packages

Another option is that you @angular your other @angular packages also to the latest version 2.4.1. Here you need to replace 2.1.1 with 2.4.1 with package.json (except for the router, which will be 3.4.1 ). Then delete the node_modules folder and run npm install again.

Here you may encounter some other problems depending on your application ... First you can check out Changelog first.


FYI: when you install the new @angular package in your project, always try to stick to the version you are using right now. To install a specific version in your case, this would be (pay attention to @2.1.1 ):

 npm install @angular/ compiler-cli@2.1.1 @angular/ platform-server@2.1.1 --save 

... or update everything to a new version; -)

+3
source

Source: https://habr.com/ru/post/1261987/


All Articles