NextJS

How to Disable Any NextJS Warning

Since NextJS log is no longer part of webpack logs, we cannot use FilterWarningsPlugin. Instead, use node level stdout filter, for example, intercept-stdout.

First, install package:

$ npm i intercept-stdout --save-dev

Then, for example, to ignore all warnings that contain the word “spida”:

const nextApp = require('next')()
const intercept = require('intercept-stdout')

nextApp.prepare().then(async () => {
    // in front of all other code
    intercept((text) => {
        if (text.match(/spida/)) return ''
        return text
    })

    ....
}

And since production doesn’t have these warnings anyway, feel free to add a if (process.env.NODE_ENV === 'development') in front.

Standard

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.