M
M
mikola742015-11-02 13:48:27
JavaScript
mikola74, 2015-11-02 13:48:27

How to run requirejs module in node?

I'm trying to run the requirejs module with node and see the message 'Executed' on the console.

requirejs = require('requirejs');
requirejs.config({
        nodeRequire: require,
        baseUrl: '/home/dev01/projects/trynode/static/app/',
        paths: { 
                lodash: '../bower_components/lodash/lodash',
                jquery: '../bower_components/jquery/jquery',
                backbone: '../bower_components/backbone/backbone',
                marionette: '../bower_components/marionette/lib/backbone.marionette',

        },

        map: {
                '*': {
                        underscore: 'lodash',
                        _: 'lodash',
                        jQuery: 'jquery',
                        $: 'jquery'
                },
        },

        shim: {
                jquery: ['jquery'],
        }

});

requirejs(['_', 'backbone'], function(_, Backbone) {
        console.log('Executed');
});

I execute >>> node module.js
Everything imports without errors, but the console is empty and the function passed to requirejs is not executed.
What is the reason?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question