ezraroi / ngJsTree

Angular Directive for the famous JS Tree
http://ezraroi.github.io/ngJsTree/
MIT License
270 stars 101 forks source link

Cannot read property 'defaults' of undefined #112

Closed gauravbhavsar closed 7 years ago

gauravbhavsar commented 7 years ago

I am using requireJs in my project.

Require config :

require.config({
    urlArgs: "bust=v2",
    waitSeconds: 200,

    paths: {
        'angular': '../Scripts/angular.min',
        'uiRouter': '../Scripts/angular-ui-router.min',
        'jquery': '../Scripts/jquery.min',
        'jquery-ui': '../Scripts/jquery-ui.min',
        'bootstrap': '../Scripts/bootstrap.min',
        'jsTree': '../Scripts/jstree',
        'ngJsTree': '../Scripts/ngJsTree.min'
    },

    shim: {
        'angular': {
            exports: 'angular'
        },
        'uiRouter': {
            deps: ['angular']
        },
        'bootstrap': {
            deps: ['angular']
        },
        'jquery-ui': {
            deps: ['jquery']
        },
        'jsTree': {
            deps: ['jquery', 'jquery-ui']
        },
        'ngJsTree': {
            deps: ['jsTree'],
        }
    },

    // kick start application
    deps: ['../Scripts/boot']
});

Gruntfile :

requirejs: {
        compile: {
            options: {
                generateSourceMaps: true,
                logLevel: 4,
                baseUrl: "base/",
                include: "./main",
                out: "dist/main.js",
                preserveLicenseComments: false,
                optimize: "uglify2",
                mainConfigFile: "scr/main.js"
            }
        }
    }
});
grunt.loadNpmTasks('grunt-contrib-requirejs');

after runing grunt I am getting error :

Uncaught TypeError: Cannot read property 'defaults' of undefined

error is in this : $.jstree.defaults.alltrigger=null

Any idea why $.jstree is undefined ?

Thanks in advance.

gauravbhavsar commented 7 years ago

Issue was in my requireJS grunt task. Solved

siecj commented 6 years ago

@gauravbhavsar I met the same error, may I know how did you resolve this issue by changing the grunt task? Thanks a lot

Bushira23 commented 6 years ago

@gauravbhavsar,

I am also seeing the same issue with webpack. Could you please assist?

Kind Regards, Rachidi

gauravbhavsar commented 6 years ago

@siecj @blowsie I was creating minified and ulgy js file using requireJS and problem with configuration.

requirejs: {
    compile: {
        options: {
            generateSourceMaps: true,
            logLevel: 4,
            baseUrl: "base/",
            include: "./main",
            out: "dist/main.js",
            preserveLicenseComments: false,
            optimize: "uglify2",
            mainConfigFile: "scr/main.js"
        }
    }
}

I change above code to

requirejs: {
        js: {
            options: {
                uglify2: {
                    mangle: false
                },
                baseUrl: "app/",
                mainConfigFile: "app/main.js",
                name: "main",
                out: "dist/main.js",
                preserveLicenseComments: false,
                optimize: "uglify2",
            }
        }
    }

this create new minified and ulgify version of js at dist/main.js and I am now using this file on production environment.

sorry for late reply :)