Can't use core/jquery I created my libraries.yml as shown in Drupal 8 CSS/JS.

.libraries.yml

 general:
  version: 1.x
  css:
    theme:
      css/materialize-custom.css: {}
      css/main.css: {}
  js:
    js/materialize.min.js: {}
    js/main.js: {}
  dependencies:
    - core/jquery


My problem is that my main.js need jQuery to work.

main.js

$( document ).ready(function() {
  // Initialize collapse button
    $(".button-collapse").sideNav();
});


I get this error. 


  


I don't understand why I have this error. What is wrong with my code?
Drupal doesn't provide you with an alias for jQuery, because these days it'll inevitably interfere with another library sometime later.

If you want $ as an alias, you'll need to create it yourself:

(function($) {
  // your code...
})(jQuery);