Update to Angular v6 - Module not found: Error: Can't resolve 'fs'

前端 未结 12 2450
栀梦
栀梦 2020-11-30 06:04

I\'m trying to migrate my Angular Universal project from Angular v5 to v6

I\'ve got a service where I use fs to load the translation on the server side.

12条回答
  •  既然无缘
    2020-11-30 06:20

    Update 2020

    See answer of Marc for Angular v9.

    Update 2019

    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.

    Original answer

    Ok after hours I come to the conclusion with the answers I gathered that the real answer is:

    You can't use fs anymore in Angular v6

    Furthermore, since it's not possible anymore to eject the webpack configuration, there is no way to tell webpack to ignore the fs require

    There is an open issue about this subject: https://github.com/angular/angular-cli/issues/10681

    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

提交回复
热议问题