RSS

Category Archives: RequireJs

Prepire Environment for RequireJS, Backbone, and Bower Starter Template on Windows

By Sochinda Tith,

Required application:

  1. Nodejs installer (http://nodejs.org/download/)
  2. Msysgit (http://msysgit.github.io/)

Download both application and install into Windows OS

Open “CMD” as administrator and run:

$ npm install bower-installer
$ npm install -g requirejs
del %HOMEDRIVE%%HOMEPATH%\AppData\Roaming\npm\r.js
DOSKEY r.js=r.js.cmd $*

*** Notation: for new version bower, we have to change component.js to bower.js

If there any error’s called javascript source map, please go to setting in browser and un-check this option.

Please follow instruction in bellow video:

Advertisements
 
Leave a comment

Posted by on June 6, 2014 in Backbone, Javascript, RequireJs

 

RequireJS and Windows: how to invoke the r.js command

By: Hajime Branko Yamasaki Vukelic

For Install r.js

npm install -g requirejs

 

If you’ve been frustrated to hell using RequireJS on Windows, and the r.js optimizerin particular, you might have witnessed things like WSH errors or your editor opening the r.js file. I’ve seen a few frustrated people post bug reports on GitHub, so I decided to post a few solutions to the issue.

Before we begin, let me note one thing. The optimizer works just fine on Windows. The documented way of running the optimizer is to use r.js.cmd command instead of just r.js, and if you stick to that recommendation you shouldn’t have any issues. In the following paragraphs, I will describe a few ways to invoke r.jswithout involving the (slightly) awkward .cmd extension.

Remove r.js file

When you install the requirejs package using npm, it will install two files in %HOMEDRIVE%%HOMEPATH%\AppData\Roaming\npm directory. One is called r.jsand another is r.js.cmd. The problem is the former. Although it has a .jsextension, it’s actually a shell script (for the uninitiated, it’s a UNIX/Linux thing), and not meant to be run with NodeJS at all.

Removing the r.js file allows you to run the r.js.cmd file without the extension. Use the following command to delete it:

del %HOMEDRIVE%%HOMEPATH%\AppData\Roaming\npm\r.js

Be sure to leave the .cmd file intact.

DOSKEY trickery

If you haven’t used DOSKEY before, you should give it a try. An article by Dan Fabulich gives you a condensed version of how to set up permanent DOSKEY macros that will load each time you open command prompt.

To set up a macro for r.js use the following command:

DOSKEY r.js=r.js.cmd $*

This will override the r.js file in the %HOMEDRIVE%%HOMEPATH%\AppData\Roaming\npm directory, and allow you to user.js without the .cmd extension. Be sure to save the macro as per Dan’s instructions.

Use a build system

This may be quite obvious, but you can use a proper build system that would call the RequireJS optimizer on your behalf. This does away with the poblem of how to invoke r.js, and also gives you other goodies commonly available in such systems. Try volo or Grunt.

volo deserves a special recommendation since it’s maintained by James Burke, author of RequireJS, and comes with a great project template that sets things up for requiring and building, and the ability to convert modules to AMD when installing from online repositories or other locations.

 

Copy From: http://www.brankovukelic.com/2013/10/requirejs-and-windows-how-to-invoke-rjs.html,

 
Leave a comment

Posted by on February 14, 2014 in Javascript, RequireJs

 

Uncaught TypeError: undefined is not a function

I had the exact same problem and I was struggling around many hours until I saw your entry here. Then I started over from scratch and now it works for me at least.

requirejs.config({
    baseUrl:'/js/',
    paths:{
      jquery:'vendor/jquery',
      handlebars: 'vendor/handlebars',
      text: 'vendor/require-text',
      chaplin:'vendor/chaplin',
      underscore:'vendor/underscore',
      backbone:'vendor/backbone',
      highcharts: 'vendor/highcharts'
    },

    shim: {
      backbone: {
        deps: ['underscore', 'jquery'],
        exports: 'Backbone'
      },
      underscore: {
        exports: '_'
      },    
      highcharts: {
        exports: 'Highcharts'
      }    
    },
});

Since I use Chaplin on top of Backbone, I am including some more files in my paths attribute. Highcharts has a similar structure to Backbone so I thought I could load it the same way. It works for me now. As you can see, I am introducing highcharts in the paths attribute already to export it as a shim afterwords.

 
Leave a comment

Posted by on January 31, 2013 in JQuery, RequireJs