0

I have a directory structure which looks like the attached screen shot [![enter image description here][1]][1]

And then in the index.php file I am including require and my app file like this

<script type='text/javascript' data-main="js/config" src='node_modules/requirejs/require.js'></script>
<script type='text/javascript' src='js/app.js'></script>

Note: I have a package.json which, I am using for getting all the dependencies I am using for this project.

my cofig.js looks like this

requirejs.config({
    baseUrl: "node_modules",
    paths: {
        jquery: "/jquery/dist/jquery.min"
    }
});

The app.js looks like this.

define(['jquery'], function($){

  //my code goes here
});

When I am loading my index.php I am getting this error in the console.

"require.js:165 Uncaught Error: Mismatched anonymous define() module: function ($){"

What am I doing wrong here? Super new to require so probably I am doing something really dumb

soum
  • 1,131
  • 3
  • 20
  • 47
  • The other question covers the error you are getting. In your particular case you are loading `js/app.js` through a `script` element. That's a no-no. You cannot load a module that uses an anonymous `define` through a `script` element. It must be loaded through RequireJS. – Louis Feb 24 '17 at 17:53
  • @Louis -- Hi Louis. Thanks for pointing that out. Can you add/ edit the code I added so that I fully understand how should I be doing this. I resolved the error though. jquery: "/jquery/dist/jquery.min"...the first "/" was causing it – soum Feb 25 '17 at 13:10

0 Answers0