Q:

Uncaught TypeError: $ is not a function in WP only when I am not log in

I am getting the following error:
Uncaught TypeError: $ is not a function

Only when I am not logged into my WP account.
I have followed the advice to change the var $ to jQuery, but still getting the same error.
Update:
Sorry I didn't put any code. Well this is the code I would like to work properly. But it doesn't work any jquery from any plugin.
I have Jquery added in my wordpress theme and the galleries were working fine until now.
<script>
jQuery(document).ready(function($) {

$('.woocommerce-MyAccount-navigation-link--customer-logout').html('<a href="https://thepuzzleclub.com.au/puzzle-club-fundraising/">Member Details</a>');
$('.woocommerce-MyAccount-navigation').children().append('<li class="woocommerce-MyAccount-navigation-link woocommerce-MyAccount-navigation-link--customer-logout"><a href="https://thepuzzleclub.com.au/my-account/customer-logout/">Logout</a></li>');
$('#affwp-affiliate-dashboard-tabs').prepend('<li class="affwp-affiliate-dashboard-tab"><a href="https://thepuzzleclub.com.au/my-account/">Account Details</a></li>');
$('#header').append('<a class="icon-member-top" href="https://thepuzzleclub.com.au/my-account/"><i class="fa fa-sign-in" aria-hidden="true"></i><span class="text-log-in">MEMBER AREA</span></a>');
$('#header').append('<a class="icon-join-top" href="https://thepuzzleclub.com.au/become-a-partner/"><i class="fa fa-truck" aria-hidden="true"></i><span class="text-log-in">JOIN THE PUZZLE CLUB</span></a>');
$(window).scroll(function() {  
    var scroll = $(window).scrollTop();

     //>=, not <=
    if (scroll >= 60) {
        //clearHeader, not clearheader - caps H
        $("#headerwrap").addClass("fixed-header");
      $("#body").addClass("spacing-top");
        $("#header").addClass("header-on-scroll");
    }
  else{
    $("#headerwrap").removeClass("fixed-header");
    $("#body").removeClass("spacing-top");
    $("#header").removeClass("header-on-scroll");
  }
});
});
</script>

Any advice on this ?

A:

I assume you load the script in your functions.php
    // add it like this
   ///includes/resources/js is the path to your script
        wp_enqueue_script( 'my-script', get_template_directory_uri() . '/includes/resources/js/my-script.js', array( 'jquery' ) );

