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

前端 未结 12 2474
栀梦
栀梦 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:16

    In Angular 8, you can now use Angular Builders to specify a web.config.js which extends the virtual config produced by Angular.

    This blogpost explains it quite well.

    tldr:

    1. run npm i -D @angular-builders/custom-webpack
    2. edit your angular.json file architect.serve and architect.build to tell it to use the custom-webpack module to extend the virtual config with your webpack.config.js file
    3. Create your custom webpack.config.js - in this case it would look like this:
    module.exports = {
        node: {
            fs: 'empty'
          }
    };
    

提交回复
热议问题