Search code examples
javascriptmoduleruntime-errorrequirejs

Uncaught Error: Script error for "core.js" - Trying simple console log from module


I'm making a Chrome extension and therefore trying to use require.js, but unsuccessful to "require" the first file to be load. What i am doing wrong?


Project details

Error:

Console Error

Project structure:

enter image description here

app.js:

var jq = $.noConflict(true);
function docReady() {

    requirejs.config({
        baseUrl: 'app',
        paths: {

        }
    });

    require(['core'], function(core) {
        core.log();
    });
}

jq(document).ready(docReady);

core.js:

define(function () {
    var methods = {};
    methods.log = function() {
        console.log('testing...');
    }

    return methods;
});

Yes, i do load require.js in content_scripts inside the manifest.json, before loading app.js

I'm trying to do something simple as displaying a console.log from my second file, but after so many tries idk what to do. May someone help me?


Solution

  • Your manifest needs to loading the core.js before or after the content load event