requirejs,js-amd,uglifyjs,r.jsView the original page-Collection of common programming errors

UnKnown Error


  • keithjgrant
    requirejs minify web-deployment 2014-2-14 12:33:23
    I’ve got some paths configured in require-config.js as follows:var require = {baseUrl: ‘/javascript’,paths: {‘jquery’: ‘jquery/jquery-1.8.1.min’// etc. — several paths to vendor files here}, }I am trying to get the optimization working for deployment. The docs say I should have a build.js that looks something like this:({baseUrl: ‘javascript’,paths: {‘jquery’: ‘jquery/jquery-1.8.1.min’},name: ‘main’,out: ‘main-build.js’ })Is there a way to have the optimizer read my config file instead of (or i

  • gremo
    node.js module requirejs amd commonjs 2014-2-14 12:12:00
    I’m a lot confused about CommonJS, AMD and RequireJS. Even after reading a lot.I know that CommonJS (previously ServerJS) is a group for defining some JavaScript specifications (i.e. modules) when the language is used outside the browser. CommonJS modules specification has some implementation like Node.js or RingoJS, right?What’s the relation between CommonJS, Asynchronous module definition (AMD) and RequireJS? Is RequireJS an implementation of CommonJS module definition? If yes, what’s AMD then

  • Ahmed Nuaman
    coffeescript requirejs gruntjs grunt 2014-2-13 12:36:38
    I have a project written in CoffeeScript that uses AngularJS. My vendor dependancies are installed using Bower and my file structure is like this:- assets- js- app- model- *.coffee- factory- *.coffee…- app.coffee- config.coffee- routes.cofeee- vendor- angular- lodash…- distWhat I’m trying to do is the following:I’m trying to work out how I can use RequireJS’s r.js to optimise my app files so that I essentially get a concatenated file all ordered nice (so vendor dependancies, my config and ro

  • madth3
    javascript jquery requirejs browser-cache 2014-2-13 9:20:31
    I’m using RequireJS (the jQuery version) and I want to append GET parameters to my scripts to prevent unwanted caching. I’m using the urlArgs parameter, as suggested in the docs. This is my app-build.js file: ({appDir: “../”,baseUrl: “scripts/”,urlArgs: “cache=v2”,…Then I build the project as follows: $ node ../../r.js -o app.build.jsThe output in app-build directory now contains both require-jquery.js, which is the same file as previously, and require-jquery.js?cache=v2, which is blank.The in

  • NPehrsson
    javascript requirejs 2014-2-12 9:14:58
    Im thinking of an html5/js mobile app, and I need to store the state of the application. I’m figuring to use RequireJS, and RequireJs does hold the instances and scripts loaded into memory at runtime.Does RequireJs have any hook where I can just ask RequireJs for all stored instances? And also, can I somehow tell RequireJs here are all your stored instances?

  • Ed .
    javascript maven requirejs web-component 2014-2-11 11:21:04
    I’m looking to layout the structure of our new web components and am currently not sure I’ve found a tool that’ll do all of what we ideally want, or comes very close, but it seems like it’d be a fairly common thing to want to do nowadays.We have a web application that is running Java server-side, while client side we use JavaScript heavily and SASS, amongst other things. We are looking to re-sturcture some of our codebase and component-ize certain aspects of our dynamic page content.For example,

  • null_radix
    javascript requirejs amd r.js 2014-2-9 6:35:38
    I have the following. require([ ‘a’, ‘b’ ], function() { if(x){require([ ‘c’, ‘d’ ], function( ) {});} });c will always be loaded with d. Is there anyway to make the optimizer optimize c and d so that they will load as one file?EDIT:Also im using r.js as the optimizer. And the modules for my build script look something like this.modules: [{name: “main”,},{name: “c”,include: [“d”]} ] This will include d in c, but both c and d are still loaded at runtime.

  • IziFortune
    javascript requirejs 2014-2-3 19:59:11
    I’m getting this error when the optimizer is launched by grunt (I’m using yeoman backbone-generator )Running “requirejs:dist” (requirejs) taskError: ReferenceError: window is not definedI’m using requirejs and the plugin i18n. This is my main.jsrequire.config({//locale: “en”,shim: {underscore: {exports: ‘_’},backbone: {deps: [‘underscore’,’jquery’],exports: ‘Backbone’},’jquery-notify’: {deps: [‘jquery’]},swiper: {deps: [‘jquery’],exports: ‘Swiper’},bstrapcollapse: {deps: [‘jquery’,’bstraptransit

  • yokks
    node.js cordova requirejs handlebars.js handlebars 2014-2-1 14:53:13
    i am using handlebars pre-compiler for compiling handlebar templates using the commandhandlebars *.tpl -f *.jsi am using handlebar.runtime-v1.1.2.js for using pre-compiled handlebar templates.When is execute the compiled template with the following codeHandlebars.template(‘****’);am getting an errorUncaught Error: Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version (>= 1.0.0) or downgrade your runtime to an o

  • bcmcfc
    javascript requirejs gruntjs 2014-1-31 16:42:08
    I’m precompiling Handlebars templates and loading them through Requirejs. Grunt creates a build and does all the precompiling and whatnot.Next step is to use Handlebars Runtime instead of the full Handlebars script.In the RequireJS config, the path to Handlebars is set:js/src/config.js:require.config({//…paths: { handlebars: ‘lib/handlebars’ }//… });For a particular Grunt task, I wish to include an option that will change this path to handlebars.runtime, so that when the whole thing is compr

  • Merc
    dojo dijit js-amd 2013-11-11 1:09:20
    This took me a while. A long while. I battled two problems at once (circular dependencies, fixed with refactoring, and this problem). To get this problem into a JSFiddle required a LOT of work… but I think it was worth it. So:http://jsfiddle.net/EVbTL/3/I define three widgets:r.AppMainScreen — This is the main app’s widget. Easy: just a bunch of tabs, and a button which contains a simple button, which goes:// SUbmit form this.form.onSubmit = function(e){e.preventDefault();console.log(“HERE”);

  • Peter
    requirejs amd js-amd r.js almond 2013-11-6 21:31:34
    In my grunt.js file I’ve gotrequirejs: {dist: {options: {almond: true,wrap: true,modules: [{name: ‘main’}],mainConfigFile: “src/js/main.js”,baseUrl: “src/js”,dir: “tmp/js”,inlineText: true,preserveLicenseComments: false}} }Running grunt requirejs:dist populates the tmp/js directory with some minified files – among others a big main.js file (everything seems to be bundled in this file as expected) – however when I want to include this file like so<script type=”text/javascript” src=”tmp/main.js

  • Cam
    javascript requirejs amd js-amd 2013-11-2 21:44:47
    I’m getting an Uncaught TypeError when i refresh the page, my js/app/main.js file can’t call the method update() on js/app/utilities/resize.js.Error outputUncaught TypeError: Object function U(n){return n&&typeof n==”object”&&!me(n)&&ne. call(n,”__wrapped__”)?W(n)} has no method ‘update’I haven’t managed to isolate/replicate the issue into a simplified working example unfortunately. But you can click on the js files within the folder tree below for gists.index.html js / a

  • Jim Rubenstein
    javascript highcharts requirejs js-amd 2013-10-20 6:57:23
    I’m attempting to load the Highcharts library using a shim in RequireJS. However, when Highcharts loads, it throws an exception because it can’t access the jQuery methods it depends on.The require config looks like so:require.config({baseUrl: “js”,shim: {‘libs/highcharts/highcharts.src.js’: {deps: [‘jquery’],exports: function(jQuery){this.HighchartsAdapter = jQuery;return this.Highcharts;}}} });The exception that is thrown is:Uncaught TypeError: undefined is not a functionand is in regards to t

  • voidstate
    javascript dojo requirejs js-amd 2013-9-17 7:36:26
    Is it possible to use require within a define block?I am trying to load the facebook JS API but need to wrap it in a require with a different context because I don’t want the whole application to stop loading if Facebook is blocked by a firewall.The problem I have is how to return the module from within the nested require() call.My code looks something like this:define( [ ‘require’ ], function( require ) {var fbRequire = require( { context: ‘fb’,waitSeconds: 3} );fbRequire.onError = function(){

  • Richard
    javascript requirejs amd js-amd 2013-9-16 18:54:47
    I am already using RequireJS to load jQuery and other plugins, as follows: var dependencies = [“order!jquery”, “order!plugins/jquery.typewatch”, “order!plugins/jquery.csv-0.71.min”, “plugins/jquery.zclip.min”]; require(dependencies, function($) {// jQuery code goes here });This works fine. I now want to use RequireJS to load a text file, so I’ve downloaded the RequireJS text plugin, and amended my code:var dependencies = [“order!jquery”, “order!plugins/jquery.typewatch”, “order!plugins/jquery.

  • David Given
    javascript js-amd 2013-9-13 23:23:32
    I am trying to write a reasonably chunky client side web app using Javascript and jQuery. In order to organise my code, I read up on Javascript module systems and decided to go with AMD modules. Currently I’m using curl.js as my module loader, but I’m not particularly wedded to that.Unfortunately I’ve now run up against an issue where two of my modules need to be mutually dependent. I was expecting it to Just Work — but what actually happens is that loading the app just seems to stall half-way

  • Dan D.
    requirejs js-amd 2013-9-9 18:20:42
    I’m successfully loading jQuery (when setting require.config)…// For details see: // http://groups.google.com/group/requirejs/browse_thread/thread/e7532b7e3013bc62/1e5ca8a89b276de6?show_docid=1e5ca8a89b276de6 require.config({ paths : { ‘jquery’ : ‘Utils/jquery’ } });I have a github repo with the entire set-up here: https://github.com/Integralist/RequireJs-ExampleMy issue is that when I try to run the build script: https://github.com/Integralist/RequireJs-Example/blob/master/Assets/Scripts/ap

  • Panu Haaramo
    dojo lotus-domino js-amd 2013-9-5 21:55:14
    When I put this on my Form (not XPage):<script src=”/xsp/.ibmxspres/dojoroot/dojo.js” data-dojo-config=”async: true, parseOnLoad: true”></script> calls like this:require([“dojox/validate/web”], function(validate) {validate.isEmailAddress(someAddress); });fail with error (this error is from Opera 12.15):Unhandled Error: Undefined variable: requireI checked with Chrome network panel that dojo.js is loaded and tried also with IE10.If I use:<script src=”//ajax.googleapis.com/ajax/libs

  • Soundstep
    javascript node.js commonjs javascript-namespaces js-amd 2013-9-5 6:07:07
    I’m trying to write a javascript module that I can load:normally in a browser (script tag) in a browser using requirejs (AMD) in node.jsI got it almost right I believe, but I’m not sure the way it should work in node.js as I didn’t use it much.The goal:create a namespace that contains stuff adding methods/properties to that namespace from other javascript filesMore specifically, I would like to create a namespace named “myns”:a “myns-before.js” would add a “before” property a “myns.js” would add

  • MrLipman
    requirejs js-amd uglifyjs r.js 2013-9-1 22:16:18
    I’m using r.js to optimize/uglify my JavaScript code which is using RequireJS.One of my modules is a polyfill module:define(function(){if (!Array.prototype.filter){ /* … */ }var isPolyfillNeeded = function () { /* … */ }if (isPolyfillNeeded()) {/* polyfill implementation */} });The module causes parsing error thrown from r.js when trying to uglify it, saying:Tracing dependencies for: ../scripts/main-app Error: Parse error using UglifyJS for file: C:/…/polyfill.js Unexpected character ‘?’

  • Edward Samson
    javascript requirejs google-closure-compiler uglifyjs 2013-8-26 18:05:26
    I’m using the RequireJS Optimizer on a project of mine and, by default, it uses UglifyJS. However, I was encountering an error (‘anim’ is undefined) when running on IE and Opera. Switching to the Closure Compiler with no other configuration change, just sticking to defaults, makes the problem go away.How can I get an effective diff of the optimized output these two tools produce?I don’t mean to compare the capabilities of the two, either way is fine with me, but this may help point out a bug in

  • Tetaxa
    javascript uglifyjs 2013-8-25 6:31:15
    I have code similar to this:(function (global) {var MyObject = function (arg1, arg2) {this.publicVar = arg1;this._internalVar = arg2;};MyObject.prototype = {publicFunc: function (param) {return param + this._internalVar;}};global.MyObject = MyObject; }(window));Can I somehow get UgilfyJS to mangle _internalVar because it is not intended to be used outside of this scope? I know it can be done with closure compiler using advanced compression etc but I’m using anvil to build and uglifyjs to minify.

  • Evan
    javascript npm minify concat uglifyjs 2013-8-24 7:49:13
    So I installed npm using npm install uglify-jsI run a command which is:cat file1.js file2.js .. fileN.js | uglifyjs -o files.min.jsand I get this error:WARN: ERROR: Unexpected token eof «undefined», expected punc «,» [-:630,15]/usr/local/lib/node_modules/uglify-js/lib/parse.js:199throw new JS_Parse_Error(message, line, col, pos);^ Errorat new JS_Parse_Error (/usr/local/lib/node_modules/uglify-js/lib/parse.js:185:18)at js_error (/usr/local/lib/node_modules/uglify-js/lib/parse.js:199:11)at croak (

  • NULL
    javascript uglifyjs 2013-8-20 10:19:04
    I was looking at the output of some stuff from UglifyJS and happened across some code like the following:var a = 0; var b = function () {return function () {a++;}(), ‘Hello, World’ }();After running that code a is 1 and b is the string Hello, World!.At first glance it appears that b will be undefined since it looks like the result of a function with no return value is being returned, but that is followed by a comma and a string literal.Why does this work? And why doesn’t UglifyJS just execute th

  • Andrew
    javascript parsing uglifyjs 2013-8-9 13:09:26
    I want to use the UglifyJS parser to check if any identifiers in a piece of code are used when they are not guaranteed to be defined.Example:// Should raise an error since myfunc and myvar have not been defined, but works var ast = jsp.parse(‘myfunc(myvar);’);I realise that myfunc and myvar are not necessarily undefined (since they could exist in scope) but I want to know when they possibly might be undefined.echo “myfunc(myvar);” | uglifyjs happily returns myfunc(myvar); and I can’t find any op

  • Jeff
    javascript node.js coffeescript uglifyjs 2013-8-8 17:47:46
    I just installed Uglify.js and tried to use it to rebuild CoffeeScript, but keep getting this error. This happens when I type “cake build:browser” in the CoffeeScript directory. (I want to try my hand at modifying the CoffeeScript language.)My Uglify.js was cloned from GitHub and the symbolic link was created in .node_libraries. Uglify is installed correctly, confirmed since it runs properly in Node and through the command line. So maybe this is a CoffeeScript problem.Help?/Users/myuser/proje

  • Dennis Burton
    javascript uglifyjs 2013-8-6 11:18:16
    The first file that I am passing to uglifyjs declares some namespaces likewindow.MyNamespace = {}when uglifyjs sees this line it complains that window is not defined. Is there a way to have uglifyjs ignore undefined symbols? I have tried using the –no-dead-code option

  • null_radix
    javascript requirejs amd r.js 2014-2-9 6:35:38
    I have the following. require([ ‘a’, ‘b’ ], function() { if(x){require([ ‘c’, ‘d’ ], function( ) {});} });c will always be loaded with d. Is there anyway to make the optimizer optimize c and d so that they will load as one file?EDIT:Also im using r.js as the optimizer. And the modules for my build script look something like this.modules: [{name: “main”,},{name: “c”,include: [“d”]} ] This will include d in c, but both c and d are still loaded at runtime.

  • Nik
    javascript backbone.js requirejs r.js 2014-1-18 5:11:53
    Scenario: Framework used are backbone and require. I have a main.js which have several dependencies on util, model and view js, which are again inter-dependent. There are cyclic dependencies also. This main.js has been compiled into a single file using requirejs optimizer.Problem: How to override certain views and models at runtime? (I have a single compiled version of main, so i am not talking about excluding the js for models or views at compile time).At compile time i don’t know whether the m

  • Louis
    javascript requirejs runtime-error bundling-and-minification r.js 2013-11-26 14:25:24
    I bundle all my JS assets into one minified uglified file via r.js (part of requirejs).If any unhandled errors occur on the browser, I use raygun (like Airbrake) to report it back to me. The only problem is the line number I get in my error message, refers to the bundled minified file. Which doesn’t help much.Is there a way to correctly map the line number of my single minified and uglified bundled asset, into the individual JS file with the correct line number?

  • Peter
    requirejs amd js-amd r.js almond 2013-11-6 21:31:34
    In my grunt.js file I’ve gotrequirejs: {dist: {options: {almond: true,wrap: true,modules: [{name: ‘main’}],mainConfigFile: “src/js/main.js”,baseUrl: “src/js”,dir: “tmp/js”,inlineText: true,preserveLicenseComments: false}} }Running grunt requirejs:dist populates the tmp/js directory with some minified files – among others a big main.js file (everything seems to be bundled in this file as expected) – however when I want to include this file like so<script type=”text/javascript” src=”tmp/main.js

  • Alexander Klimetschek
    requirejs r.js 2013-9-19 16:50:50
    I am trying to integrate the r.js optimizer on the server side (Apache Sling) and face one problem: when resolving modules it always looks them up under the output directory (dir), not from within the source directory (baseUrl or appDir), doesn’t find them and thus fails./project/build.js({name: “modules/main”,dir: “/target”,baseUrl: “/sources” })If you wonder, the root path / is inside the server’s JCR repository, not a file system. Also I simplified the example a bit (hopefully without conceal

  • Toddish
    backbone.js requirejs r.js 2013-9-18 8:49:16
    When I run the r.js optimizer over my Backbone.js app, I get this error:Uncaught TypeError: undefined is not a functionIt appears in the middle of the Backbone.js section of the output.I removed bits of code until I found out what was causing it, and it seems to be when I call Backbone.history.start();.I’ve created a simple app to replicate the bug, which I’ve posted below. Basically, it creates a route and ‘console.log’s ‘home’. It works fine when not optimized.To optimize the app, I use:node r

  • DJ Forth
    requirejs ruby-on-rails-4 r.js 2013-9-8 22:00:59
    I am using Require.js in a rails 4 application. However in the production environment I’d like to compile into 1 file and use almond. Now obviously require.js recommends r.js, which even has a coffeescript plugin for it, but would mean running it outside of rails manually. There is the requirejs-rails gem, but this seems to have not been updated for a while and doesn’t have rails4 support. There is a couple of forked version but I get an error when I try to use them:`user_config=’: undefined

  • MrLipman
    requirejs js-amd uglifyjs r.js 2013-9-1 22:16:18
    I’m using r.js to optimize/uglify my JavaScript code which is using RequireJS.One of my modules is a polyfill module:define(function(){if (!Array.prototype.filter){ /* … */ }var isPolyfillNeeded = function () { /* … */ }if (isPolyfillNeeded()) {/* polyfill implementation */} });The module causes parsing error thrown from r.js when trying to uglify it, saying:Tracing dependencies for: ../scripts/main-app Error: Parse error using UglifyJS for file: C:/…/polyfill.js Unexpected character ‘?’

  • Dan Ramos
    javascript requirejs grunt r.js 2013-8-21 14:10:08
    I’m able to successfully compile my JS modules via Grunt’s requirejs task, but I’m getting undefined with any shim scripts. Here is my configrequirejs.config({“baseUrl”: “../../../components/”,”paths”: {“less”: “less.js/dist/less-1.3.3″,”datepicker”: “jquery-ui/ui/jquery.ui.datepicker”,”jquery”: “jquery/jquery”,”jqueryui”: “jquery-ui/ui/jquery-ui”,”spectrum”: “spectrum/spectrum”,”class”: “class/class”,”underscore”: “underscore-amd/underscore”,”d3″: “d3/d3″,”nv”: “nvd3/nv.d3″,”dataTables”: “data

  • Geoff
    optimization requirejs r.js 2013-8-7 10:17:43
    I might be missing something here (it could be a RTFM).I am trying to use the requirejs optimizer to optimize a file and require it. but the value always comes back undefined. I created the most simple test.My module (Models/Test.js):define(function () {return “from module”; });My module after I run r.js: (Models/Test-built.js):define(‘MODELS/Test’,[],function () {return “from module”; });When I include the original in a page:<script>require([‘Models/Test’], function (item) {console.log(i