在严格模式代码中,只能在顶层声明函数

时间:2019-06-07 11:57:36

标签: next.js

OS; Windows 10专业版
下一个:8.1.0

因此,我在next.config.js中添加了webpack \ Uglify部分,以防止在构建时/运行时进行字符压缩,这会导致上述错误消息。我在这里俯瞰什么?

next.config.js

module.exports = {
    onDemandEntries: {
        maxInactiveAge: 25 * 1000,
        pagesBufferLength: 6
    },
    webpack(config, options) {
        config.optimization.minimizer = config.plugins.filter(
          (plugin) => (plugin.constructor.name !== 'UglifyJsPlugin')
        )
        config.optimization.minimizer.push(
        new UglifyJsPlugin({
            uglifyOptions: {
                output: {
                    ascii_only: true,
                },
            },
        })
        );
        return config;
    }
}

生成的错误如下:

[ error ] static/runtime/main.js from UglifyJs
In strict mode code, functions can only be declared at top level or immediately within another function. [static/runtime/main.js:6762,4]
> Ready on http://localhost:7777
[ event ] client pings, but there's no entry for page: /items
TypeError: Cannot read property 'issuer' of undefined
    at findEntryModule (C:\Users\d0475\Documents\Projects\flamingo-ecom2\sick-fits\frontend\node_modules\next\dist\server\hot-reloader.js:60:16)
    at erroredPages (C:\Users\d0475\Documents\Projects\flamingo-ecom2\sick-fits\frontend\node_modules\next\dist\server\hot-reloader.js:68:29)
    at HotReloader.getCompilationErrors (C:\Users\d0475\Documents\Projects\flamingo-ecom2\sick-fits\frontend\node_modules\next\dist\server\hot-reloader.js:308:33)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
TypeError: Cannot read property 'issuer' of undefined

0 个答案:

没有答案