I just had this issue myself and was able to fix it by assigning it to the script that required the data and not to “jquery”, example below:
wp_localize_script('jquery', 'vars', $vars);
wp_localize_script( 'replace-with-your-script-name', 'vars', $vars);
To clarify: This would be the same name that was used to identify in wp_enqueue_script() and should match it.