I am creating a demo for using the TheIntern test framework. When I try to load test module demo/intests/data I keep getting this error:

Defaulting to "console" reporter
Error: Failed to load module demo/intests/data from http://localhost:8081/dojo_playground/tutorials/demo/intests/data.js (parent: *12)
    at /home/bogdanbiv/.nvm/v0.10.24/lib/node_modules/intern/node_modules/dojo/dojo.js:754:12
    at fs.js:207:20
    at Object.oncomplete (fs.js:107:15)

However, accessing this file from the browser is ok, here are the server logs:

~/Projects$ http-server -p 8081 ./
Starting up http-server, serving ./ on port: 8081
Hit CTRL-C to stop the server
[Sat, 22 Mar 2014 13:06:55 GMT] "GET /dojo_playground/tutorials/demo/intests/data.js" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/32.0.1700.107 Chrome/32.0.1700.107 Safari/537.36"

I tried creating a module as simple as possible in demo/intests/data:

define({
    greeting: "Hello!",
    howAreYou: "How are you?"
});

define([], function(){});

Data:

  • Application root is at $HOME/Projects/dojo_playground/tutorials/
  • Module demo/intests/data is located at *$HOME/Projects/dojo_playground/tutorials/demo/intests/data.js*
  • Intern configuration: http://pastebin.com/hyi55qp7.
  • webserver is Nodejitsu's http-server, which is run run from localhost, webroot is $HOME/Projects
有帮助吗?

解决方案

There are at least two issues here:

  1. You’re trying to load a module from the filesystem using an HTTP URL as the path. This won’t work, for hopefully obvious reasons. You need to fix your configuration so that it is not trying to generate URLs, but rather relative paths that can be used both with a filesystem or with a network request, by not specifying an absolute URL for the loader’s baseUrl property.
  2. You can’t define two values for a single module; you should have no more than one define call per module.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top