AngularJS JS SDK @ CLI: ReferenceError: angular is not defined

491 views
Skip to first unread message

David Wu

unread,
Jun 3, 2014, 8:32:28 PM6/3/14
to loopb...@googlegroups.com








(function (exports, require, module, __filename, __dirname) { angular.module('


                                                              ^


ReferenceError: angular is not defined


    at Object.<anonymous> (.../mobileApp/www/app/app.js:1:63)


    at Module._compile (module.js:456:26)


    at Object.Module._extensions..js (module.js:474:10)


    at Module.load (module.js:356:32)


    at Function.Module._load (module.js:312:12)


    at Module.require (module.js:364:17)


    at require (module.js:380:17)


    at Object.<anonymous> (/usr/local/lib/node_modules/loopback-angular-cli/bin/lb-ng:24:11)


    at Module._compile (module.js:456:26)


    at Object.Module._extensions..js (module.js:474:10)


I'm attempting to use the AngularJS JavaScript SDK provided by you guys, but I'm a bit stuck on just getting it up. I'm following the directions found here: http://docs.strongloop.com/display/DOC/AngularJS+JavaScript+SDK#AngularJSJavaScriptSDK-CLIalternative

The command giving me the error is:

$ lb-ng path/to/app.js js/lb-services.js

I'm inside my www/app dir when running $ lb-ng ./app.js lb-services.js. 

Anybody have clues as to why the error is being thrown? `angular` doesn't have to be defined in my app.js. All I have is a module definition in here:

angular.module('myApp', []);

Any help is greatly appreciated! Thanks in advance. :)

Sean Brookes

unread,
Jun 3, 2014, 10:17:36 PM6/3/14
to David Wu, loopb...@googlegroups.com
you should run all commands from your project root, not your www/app root.


--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering.

David Wu

unread,
Jun 4, 2014, 12:58:59 AM6/4/14
to loopb...@googlegroups.com, dwu...@gmail.com
Thanks for the response, Sean, but that still doesn't work. The documentation reads, "In the directory that contains your client application, enter these commands:"
$ mkdir js
$ lb-ng path/to/app.js js/lb-services.js

I've tried it at my project root as well as a level down to my www/. The same error is still thrown. The documentation says relative paths. I've also tried full paths. The error message seems to indicate that it's reading my app.js and then saying angular is not defined. 

Any other ideas?

David Wu

unread,
Jun 4, 2014, 3:10:30 AM6/4/14
to loopb...@googlegroups.com
Resolved my own issue. Specifying wrong app.js. Had some dinner, came back, and realized that the app.js was supposed to be my loopback server's app.js and not my client-side Angular app's app.js. Whoopsies!

Sean Brookes

unread,
Jun 4, 2014, 10:25:43 AM6/4/14
to David Wu, loopb...@googlegroups.com
great news.  It can be a little confusing with a client and server 'app.js'
Reply all
Reply to author
Forward
0 new messages