$ is not a function

I’m starting to build a theme with Sage and I’m having some problems loading script files.
I understood that I have to use the manifest.json file and so I did:

  "dependencies": {
    "main.js": {
      "files": [
      "main": true

I’m trying to add a plugin I wrote, which uses the factory pattern. Its structure is basically this:


    if (typeof define === 'function' && define.amd) {
        define(['jquery'], factory);
    } else if (typeof exports !== 'undefined') {
        module.exports = factory(require('jquery'));
    } else {


     var Plugin = (function(element, settings){

        return _Plugin;



var args = {


I cut away most of the code, it’s just to give you an idea. Anyway, when I load the page I get the error “$ is not a function”. What am I doing wrong?
I tried with a simple script, like this:

(function($) {

and it works. How can I do to make the plugin to work?


WordPress enqueues jQuery in no-conflict mode. This link might be helpful.

1 Like