Reputation: 534
I have been working on a Hottowel project when Durandal 2.0 came out, so I upgraded, naturally. It kind of messed up the file structure, moved require.js
and durandal
folder to Scripts
folder etc. I ended up moving the durandal
folder back to the App
folder, as in the original Hottowel template and pointing to require.js
in the Scripts
folder in index.cshtml
.
But suddenly, I get these errors on page load:
GET http://localhost:7153/App/jquery.js 404 (Not Found) require.js:1880
GET http://localhost:7153/App/plugins/history.js 404 (Not Found) require.js:1880
GET http://localhost:7153/App/knockout.js 404 (Not Found) require.js:1880
I am loading jQuery and knockout bundled (using ASP.NET bundling) before loading require and starting durandal:
@Scripts.Render("~/scripts/vendor")
@if(HttpContext.Current.IsDebuggingEnabled) {
<script type="text/javascript" src="~/Scripts/require.js" data-main="@Url.Content("~/App/main.js")"></script>
} else {
<script type="text/javascript" src="~/App/main-built.js"></script>
}
Any idea how to fix it? I would hate to have to go back to Durandal 1.2.
Upvotes: 0
Views: 1153
Reputation: 8510
Consider where require is trying to find the file. If, for instance, http://localhost:7153/App/jquery.js
is causing a 404, then I assume it's because the file isn't in that location.
RequireJS will load a resource based on the baseUrl, if specified, in conjunction with any paths that are set up as part of any require.config()
calls.
See if you can find where jQuery is being specified as a dependency to a define'd module, or where it is being require'd. i assume it's just being requested as 'jquery'.
In that case, you're going to need to tell require where jQuery lives. Same for knockout. For the Durandal stuff, you may need to repoint the entire durandal folder to somewhere specific, depending o nwhere you located the files.
your require config call might look something like this:
require.config({
baseUrl: '/',
paths: {
'jquery': 'scripts/jquery',
'knockout': 'scripts/knockout-debug',
'durandal': 'scripts/durandal'
}
});
If possible, check out the Durandal samples for 2.0 and you'll see the require.config()
that is used in the samples, and you can compare that to your folder structure.
Upvotes: 1