node.js - RequireJs Module in node always returns undefined when using in a grunt task -


i've small config file need in frontend , in grunt task.

js/config.js:

define(function() {   return [     {       id: 'demo',       displayname: 'demo'     }   ]; }); 

i can load file in frontend without problems work in node. var requirejs = require('requirejs');

requirejs.config({   noderequire: require,   baseurl: './js' });    var config = requirejs('config') 

but when try load same file in grunt task returns undefined:

requirejs.config({   noderequire: require,   baseurl: './js' });    grunt.registertask('lala', function  () {   var config = requirejs('config') }); 

the problem require requirejs outside of module.exports function. works after all:

module.exports = function(grunt) {    var requirejs = require('requirejs');    requirejs.config({     noderequire: require,     baseurl: './js/cfe/app/platforms/as'   });    grunt.registertask('lala', function  () {     var config = requirejs('config')   }); } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -