2

I'm fairly new to Angular and NodeJS and trying to run a sample website.

From what I understood, to run it I simply need to execute "node app.js".

However, I get the following error:

C:\app\app.js:3
angular
^

ReferenceError: angular is not defined
at Object.<anonymous> (C:\app\app.js:3:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3

My app.js looks like this:

'use strict';

angular
  .module('apmportal', [
    'ngCookies',
    'ngResource'
])

The project's structure is:

The project's structure is:

Here is the index.html:

  <!-- build:js scripts/vendor.js -->
  <!-- bower:js -->
  <script src="bower_components/jquery/dist/jquery.js"></script>
  <script src="bower_components/angular/angular.js"></script>
  <script src="bower_components/angular-resource/angular-resource.js">

App folder structure:

enter image description here

I should mention that node is installed and I've also ran bower install to install all dependencies. Clearly I'm missing something here but I just cant figure out what.

Appreciate your help.

0

1 Answer 1

3

You cannot run node app.js because app.js is your front-end file. create server.js outside in your project structure and serve app/index.html from that(you should have index.html inside app folder). then run node server.js

If you don't have idea about set up backend check this project structure

Project Structure

In my case I have server code in app.js so it would be node app.js in my case

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

Comments

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.