美文网首页
【应用SSR-nuxt开发日记1】之提示fs net 等库未安装

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

作者: 懒先森 | 来源:发表于2017-08-21 16:18 被阅读229次

这个锅是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'
                })
            }
        }

参考来源

相关文章

网友评论

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

      本文链接:https://www.haomeiwen.com/subject/qixhdxtx.html