Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18nfile: Path must be a string or a buffer #3625

Closed
ghost opened this issue Dec 19, 2016 · 8 comments · Fixed by #3787
Closed

i18nfile: Path must be a string or a buffer #3625

ghost opened this issue Dec 19, 2016 · 8 comments · Fixed by #3787
Assignees
Labels
needs: investigation Requires some digging to determine if action is needed

Comments

@ghost
Copy link

ghost commented Dec 19, 2016

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Windows 10

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

$ ng --version
angular-cli: local (v1.0.0-beta.23, branch: master)
node: 6.9.2
os: win32 x64

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

ng build --aot --locale zh --i18nFormat xtb --i18nFile "./src/i18n/messages.zh.xtb"

error:

$ ng build --aot --locale zh --i18nFormat xtb --i18nFile './src/i18n/messages.zh.xtb'
Hash: 81af1eecaeec3091ea3e
Time: 5732ms
chunk    {0} main.bundle.js, main.bundle.map (main) 9.52 kB {1} [initial] [rendered]
chunk    {1} vendor.bundle.js, vendor.bundle.map (vendor) 1.25 MB [initial] [rendered]
chunk    {2} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]

ERROR in path must be a string or Buffer

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './app/client.module.ngfactory' in 'C:\projects\Dev\src\client\src'
 @ ./src/main.ts 4:0-70
 @ multi main

ERROR in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
Module not found: TypeError: Cannot convert undefined or null to object
 @ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js 69:15-36 85:15-102
 @ ./~/@angular/core/src/linker.js
 @ ./~/@angular/core/src/core.js
 @ ./~/@angular/core/index.js
 @ ./src/main.ts
 @ multi main

If I omit i18nfile, it works fine.
So it seems it cannot find the file. I've tried all options, also tried using quotes, single quotes, double quotes, etc as per @tdesmet his previous suggestion. Tried typescript@2.0.3 as well as 2.1.4 as suggested by @hansl before.
Also tried using full paths, and relative paths. About relative paths, the i18n folder is in /src/i18n; the app is in /src/app. Not sure if that makes a difference?

@ghost
Copy link
Author

ghost commented Dec 19, 2016

Found the solution: I had to use i18n-file instead of i18nFile...
This works:

 ng build --aot --locale zh --i18n-format xtb --i18n-file src/i18n/messages.zh.xtb

But why is i18nFile accepted by ng as well?

@tdesmet
Copy link
Contributor

tdesmet commented Dec 19, 2016

The commands are indeed --i18n-file, --i18n-format and --locale
The cli just ignores i18nFile.

Because you are passing locale angular compiler is expecting --i18n-file, since you did not give it to the cli a null value is passed on to the compiler.

@ghost
Copy link
Author

ghost commented Dec 19, 2016

@tdesmet thanks for your reply. I figured something like that indeed. Maybe good to have some validation?
And why does Angular CLI accept i18nFormat? Because on .beta-21 it will throw an error as your PR is not merged yet in .beta-21...

@tdesmet
Copy link
Contributor

tdesmet commented Dec 19, 2016

I have no idea, I'm just guessing here :), might be I made a mistake somewhere...

@ghost
Copy link
Author

ghost commented Dec 19, 2016

it's working now, but I've spent hours on debugging this... Until I found your unit test, and I found out I had made a typo...

@hansl
Copy link
Contributor

hansl commented Dec 30, 2016

Seems like there's a bug with the way flags are resolved. The i18nFile seems to work here locally. We'll investigate.

@hansl hansl added the needs: investigation Requires some digging to determine if action is needed label Dec 30, 2016
@hansl hansl self-assigned this Dec 30, 2016
@hansl
Copy link
Contributor

hansl commented Dec 30, 2016

Found the source cause and coming up with a fix; Ember-CLI treats --i18nFormat as a boolean, while it should be a string.

hansl added a commit to hansl/angular-cli that referenced this issue Dec 30, 2016
Previously this resulted in weird behaviour, now we automatically add an alias for the camelize version of the flag name.

Fixes angular#3625.
hansl added a commit to hansl/angular-cli that referenced this issue Feb 7, 2017
Previously this resulted in weird behaviour, now we automatically add an alias for the camelize version of the flag name.

Fixes angular#3625.
hansl added a commit that referenced this issue Feb 7, 2017
Previously this resulted in weird behaviour, now we automatically add an alias for the camelize version of the flag name.

Fixes #3625.
MRHarrison pushed a commit to MRHarrison/angular-cli that referenced this issue Feb 9, 2017
Previously this resulted in weird behaviour, now we automatically add an alias for the camelize version of the flag name.

Fixes angular#3625.
asnowwolf pushed a commit to asnowwolf/angular-cli that referenced this issue Apr 12, 2017
Previously this resulted in weird behaviour, now we automatically add an alias for the camelize version of the flag name.

Fixes angular#3625.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: investigation Requires some digging to determine if action is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants