【应用SSR-nuxt开发日记1】之提示fs net 等库未安装问题

这个锅是webpack的 但是还是加上nuxt的标签吧
在nuxt.config.js中加入node配置项和json-loader
记住只有在extend中的获取的config对象为全量的webpack参数

/*
         ** Run ESLINT on save
         */
        extend(config, ctx) {
            if (ctx.dev && ctx.isClient) {
                config.node = {
                    console: true,
                    fs: 'empty',
                    net: 'empty',
                    tls: 'empty'
                }
                // config.target = 'node'
                config.module.rules.push({
                    enforce: 'pre',
                    test: /\.(js|vue)$/,
                    loader: 'eslint-loader',
                    exclude: /(node_modules)/
                })
                config.module.rules.push({
                    test: /\.json$/,
                    loader: 'json-loader'
                })
            }
        }

参考来源

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容