2017-09-08 1 views
2

저는 Angular와 NodeJS를 처음 사용하고 샘플 웹 사이트를 실행하려고합니다.각도가 nodejs를 사용하여 정의되지 않았습니다.

내가 이해 한대로 실행하려면 간단히 "노드 app.js"를 실행해야합니다.

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 

내 app.js는 다음과 같습니다 : 여기

The project's structure is:

입니다 :

'use strict'; 

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

프로젝트의 구조는

그러나, 나는 다음과 같은 오류가 발생합니다 index.html :

,363,210
<!-- 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"> 

응용 프로그램 폴더 구조 :

enter image description here

내가 해당 노드가 설치되고 나는 또한 정자 모든 종속성을 설치하려면 설치 쳤어요 언급해야한다. 분명히 나는 ​​여기에서 뭔가를 놓치고 있지만, 나는 무엇을 알아낼 수 없다.

감사합니다.

답변

3

app.js가 프런트 엔드 파일이기 때문에 노드 app.js를 실행할 수 없습니다. 프로젝트 구조 외부에 server.js를 만들고 app/index.html을 제공하십시오 (응용 프로그램 폴더 내에 index.html이 있어야합니다). 다음 실행 노드 server.js

당신은 설정 백엔드 검사에 대한 생각이없는 경우이 프로젝트 구조는 노드가 될 것이다, 그래서 내 경우

Project Structure

나는 app.js에서 서버 코드를 내 케이스에 app.js

관련 문제