Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7915787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:34:30+00:00 2026-06-03T14:34:30+00:00

require.config({ paths: { jquery: ‘libs/jquery’, underscore: ‘libs/underscore’, } }); define([ ‘jquery’, ‘underscore’, ], function($,_){

  • 0
require.config({
     paths: {
         jquery: 'libs/jquery',
         underscore: 'libs/underscore',
    }
});
define([
    'jquery',
    'underscore',
    ], function($,_){
        var test = _.template("hello: <%= name %>",{name:"warren"});

});

Given the above code using requirejs to load jquery and underscore, why am I getting this error…

Uncaught TypeError: Cannot call method 'template' of null

All JS seems to be loading… The error points to the _.template line. This is driving me crazy…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:34:32+00:00Added an answer on June 3, 2026 at 2:34 pm

    Are you sure you’ve bundled the underscore library to be usable with requireJS ?

    When you write :

    define([
        'jquery',
        'underscore',
      ], function($,_){
          var test = _.template("hello: <%= name %>",{name:"warren"});
    
    });
    

    The ‘_’ variable (second argument of the callback function) is assigned with the export of the underscore library (second dependency specified).

    I guess you used the original version of underscore, which is not package for requireJS.
    In your underscore.js file, add the following line at the begining:

    define(function () {
    

    and this line at the end:

    return _;});
    

    Thus, the export are well configured.

    Another possible solution is to use the global ‘_’ variable: all you need to do is to remove the second argument of your callback.

    define([
        'jquery',
        'underscore',
      ], function(){
          var test = _.template("hello: <%= name %>",{name:"warren"});
    
    });
    

    From there, your browser will use the ‘_’ global variable, which is defined in underscore, and which is set when the callback is called.

    Same behaviour is expected with jQuery.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hallo I have this script: <? require(lib2/config.inc.php); require(lib2/tpl.class.php); require(lib2/db.class.php); require(lib2/um.class.php); $tpl = new template(templates,
I'm a RequireJS noob. When I use require.config and include a path to jQuery
i am using this code to define the directory paths of my project: config.php
I want to change the logging level of an application (ruby). require 'logger' config
PHP PDO Singleton Class: <?php require_once('app/config.php'); // Require constants HOST, DATABASE, USER, PASSWORD /*
require_once('/recaptcha/recaptchalib.php'); was in the correct place but the error says: Warning: require_once() [function.require-once]: open_basedir
I have a program that I use on several sites. It uses require('config.php'); to
I've got a problem with Spork test server. If I set config.cache_classes = false
I am developing a web application. contents are: root dir (/var/www/) config.php index.php details.php
With require.js, can you specify the order! plugin to be used within the 'paths'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.