2

I'm a node.js novice and after going through a simple tutorial, I've tried to load up an open source application that uses node.js and I'm getting the error below. I'm sure it's a trivial configuration issue, but I'm not seeing it.

ReferenceError: angular is not defined
    at Object.<anonymous> (d:\projects\nodeapp\app\app.js:7:15)
    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 Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

Here is the app.js where the error is occuring.

/**
 * App bootstrap script   <----- START OF FILE
 */

'use strict';

var nodeapp = angular.module('nodeapp', ['ngRoute', 'ngSanitize', 'ngAnimate']);  <----- ERROR

Here is the index.html

<!doctype html>
<html ng-controller="AppCtrl">
<head>
    <meta charset="utf-8">
    <title>App</title>

    <link href="./visual/css/main.css" rel="stylesheet" type="text/css">

    <script src="./bower_components/jquery/jquery.min.js"></script>
    <script src="./bower_components/angular/angular.js"></script>
    <script src="./bower_components/angular-sanitize/angular-sanitize.js"></script>
    <script src="./bower_components/angular-route/angular-route.js"></script>
    <script src="./bower_components/angular-animate/angular-animate.js"></script>

    ... more scripts ...

    <script src="./app.js"></script>

</head>
<body class='app-not-ready'>

    <ng-view></ng-view>

    <div class="notification-bar"
        ng-if="notificationBarVisible"
        ng-animate
        ng-bind="notificationMessage"></div>

</body>
</html>

Here is the folder structure

Folder Structure

4
  • Oh, are you run node app.js? Angular is frontend javascript framework. Or, may be, I don't understand you. Commented Sep 29, 2014 at 21:08
  • @dizel3d Yes. When I run node app.js, I get the error above. Commented Sep 29, 2014 at 21:12
  • @dizel3d If I run master/app.js I get cannot find express. If I run master/public/app.js I get cannot find angular. Commented Sep 29, 2014 at 21:17
  • you need install nodejs modules node install. I wrote an answer. Commented Sep 29, 2014 at 21:22

1 Answer 1

3

You just confused. =) AngularJS is frontend JavaScript framework and work on client side (browser) only. NodeJS is a platform for writing server side. Take a simple example NodeJS application on Express framework. https://github.com/dizel3d/bicycles. First of all you need install NodeJS and it's modules (run in project root directory in command line node i). Start node app.js and open http://localhost:3000.

Sign up to request clarification or add additional context in comments.

3 Comments

I have node installed and I understand that node is a server side language and angular is a front end framework. From what I've read, they should be able to work together (ie. MEAN stack)
Together means node.js on the back-end and AngularJS on the front-end, in the browser.
I think I see what you're saying. You're saying that I'm trying to run the angular "app.js" with node, when I should be trying to run the node "app.js" with node.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.