About webpack Packaging Tip Template execution failed: 'xxx' is not defined

(it is too troublesome to repeat the problem due to requirements and other reasons) here is what kind of effect I want to achieve:

  created () {
    console.log(userInfo)
  }

if the userInfo here has not been defined, I want to print out the error report of null or undefined, instead of webpack. I hope the god can tell me what I need to configure in webpack or what to configure in eslint

Apr.25,2021

using undefined variables directly in js is bound to report an error. It is impossible to understand what requirement must be written in this way.
if it is a global variable, you can use console.log (window.userInfo) , but with this requirement, I think there must be a logical problem

.
Menu