更新时间:2022-06-12 09:32:29
好几个小时后,我得出的结论是我得出的答案是,真正的答案是:
Ok after hours I come to the conclusion with the answers I gathered that the real answer is:
您不能再在Angular v6中使用fs
You can't use fs
anymore in Angular v6
此外,由于无法再弹出webpack配置,因此无法告诉webpack忽略fs require
Furthermore, since it's not possible anymore to eject the webpack configuration, there is no way to tell webpack to ignore the fs require
关于此主题有一个未解决的问题: https://github.com/angular/angular-cli/issues/10681
There is an open issue about this subject: https://github.com/angular/angular-cli/issues/10681
PS:我正在使用fs在服务器端加载翻译,我通过遵循@xuhcc的解决方案解决了该问题,请参见 https://github.com/ngx-translate/core/issues/754
P.S.: I was using fs to load the translations on the server side, I overcome the problem by following solution of @xuhcc, see https://github.com/ngx-translate/core/issues/754
更新2019
请参阅评论,根据@Tahlil,现在有可能.这适用于Angular v8(常春藤编译器)查看此答案.它将特定模块设置为false以便在package.json中的浏览器中使用.
See comment, according @Tahlil it is now possible. This works for Angular v8 (Ivy compiler) see this answer. It sets specific modules to false for use in the browser in package.json.