Wednesday, October 18, 2017

Angular i18n issue - Cannot read property 'toLowerCase' of null

After following the steps in the Angular documentation to setup internationalization(i18n) support, I tried to execute my brand new i18n npm command:

PS C:\Projects\test\AngularLocalization\angularlocal> npm run i18n

> angularlocal@0.0.0 i18n C:\Projects\test\AngularLocalization\angularlocal

> ng-xi18n

TypeError: Cannot read property 'toLowerCase' of null

    at Extractor.serialize (C:\Projects\test\AngularLocalization\angularlocal\node_modules\@an

gular\compiler-cli\src\extractor.js:47:32)

    at C:\Projects\test\AngularLocalization\angularlocal\node_modules\@angular\compiler-cli\sr

c\extractor.js:33:33

    at process._tickCallback (internal/process/next_tick.js:109:7)

    at Module.runMain (module.js:606:11)

at run (bootstrap_node.js:389:7)

    at startup (bootstrap_node.js:149:9)

    at bootstrap_node.js:502:3

Extraction failed

npm ERR! Windows_NT 10.0.15063

npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\

npm\\bin\\npm-cli.js" "run" "i18n"

npm ERR! node v6.11.3

npm ERR! npm  v3.10.10

npm ERR! code ELIFECYCLE

npm ERR! angularlocal@0.0.0 i18n: `ng-xi18n`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the angularlocal@0.0.0 i18n script 'ng-xi18n'.

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 angularlocal package,

npm ERR! not with npm itself.

npm ERR! Tell the author that this fails on your system:

npm ERR!     ng-xi18n

npm ERR! You can get information on how to open an issue for this project with:

npm ERR!     npm bugs angularlocal

npm ERR! Or if that isn't available, you can get their info via:

npm ERR!     npm owner ls angularlocal

npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:

npm ERR!     C:\Projects\test\AngularLocalization\angularlocal\npm-debug.log

Whoops! This was not the output I was hoping for…

Strange! Because it worked perfectly before Confused smile. A search through the issues on GitHub brought me to the following issue: https://github.com/angular/angular/issues/16235

The issue seems to have appeared in Angular 4.0.3. Luckily a workaround exists, I altered the commando in my package.json to include the prefered format:

image

When I invoked the i18n command again, this time it worked without a problem.

No comments: