Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

220
Views
Why require() gives me an undefined?

Why require.js gives me an undefined?

I try to use require.js, and create a load file use data-main = "load" in html, here is load.js:

requirejs(["script/app.js"]);

and in app.js, when I tried to load method, I received cannot read property of undefined, so I console.log(enter), and I received undefined

define(function(require) {
    var enter = require("./modules");
    console.log(enter); // shows 'undefined'
}); 

and this is modules.js:

define("post", ["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.post = void 0;
    function post(message) {
        console.log("! Message: " + message);
    }
    exports.post = post;
});
define("main", ["require", "exports", "post"], function (require, exports, post_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.entry = void 0;
    function entry() {
        (0, post_1.post)("Hello, World!");
    }
    exports.entry = entry;
});

but modules.js is exist, value of 'enter' shouldn't be undefined. What's happen?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!