Search code examples
javascriptangularjscreatejs

I get an error in CreateJS: "createjs is not defined"


I have a problem with creatJS I hope you can help.

 var stage = new createjs.Stage(canvas);

I got this error :

angular.js:13642 ReferenceError: createjs is not defined. even thought i get the EaselJS in my bower-components.

Thanks


Solution

  • I had a similar problem - in my case I added the createjs-module npm package for webpack (I use it in the Laravel wabpack mix). It appeared that there was an issue with the scope, so I had to ensure that createjs is global. So you can try to do the following:

    1. Install the npm module (in the console)

      npm install createjs-module --save
      
    2. Initialize the createjs (in your js file)

      this.createjs = {};
      
    3. Make createjs global (in your js file)

      window.createjs = this.createjs;
      
    4. Import the module (in your js file)

      require('createjs-module');
      

    And now you can use it as usual :)

    Reference: CreateJS GitHub Issues