Uğur KURT Uğur KURT - 4 years ago 86
Javascript Question

Requirejs function return error

My main.js file contains this code:


and my module.js file contains

var hasReturn = function(){
console.log("This returns");

return hasReturn;

But when I try to run this script my browser throws a type error,tells me f is not function.I ve searched for this but couldnt find anything helpful,sorry if posted before.

Answer Source

Do you have setting for libraries/modules base path? Try this

<script type="text/javascript">
            baseUrl: '@Url.Content("~/Content/js")',
            waitSeconds: 45,
               // dependencies here ex. jquery

Or explicitly put the path where the module located?


file : mymodule.js

Updated : I guess your problem is name of the module conflict somewhere else. Try to change the name of the module both file and in require. This will solve your problem. No need to add path if they both exists in same location

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download