V
V
vasIvas2015-08-17 14:04:06
JavaScript
vasIvas, 2015-08-17 14:04:06

How to correctly specify the paths in the config?

// project structure:

/
    src/
        js/
           main.js
        index.html
    test.js

at the root of the project is the src folder and the file that
I created to check for performance, in which
define is written. js contains the main.js file, which describes the
config and the code to start. So in js there are other files and they are
normally connected. index.html contains
require.js and is also the entry point for browser-sync.
// here is the config itself:
requirejs.config({
    baseUrl: "/src/js/",
    paths: {
        test: "/test.js"
    }
});


var paths = ['test'];
var factory = function(Test){
    console.log(Test);
};

require(paths, factory);

But this is how the error pops up -
Error: Script error for: test
requirejs.org/docs/errors.html#scripterror

How to specify the correct path?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex, 2015-08-17
@vasIvas

I don't think the leading slash is needed. Either src/jsand test.jsor ./src/jsand ./test.js. Unless, of course, requirejs has standard globs, and not some invention of its own.

D
Denis Ineshin, 2015-08-17
@IonDen

You missed a quote in test. Look, even the backlight is broken.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question