ReferenceError:在WebStorm中未定义angular度

我对AngularJS来说是全新的,我可能已经错过了在WebStorm中启动一个新的AngularJS项目的一些关键但不明显的步骤。

我安装了Node.JS,安装了npm的Angular,我甚至安装了bower,我甚至在凉亭里安装了angular,但是在这一点上,我不知道我缺less什么。

在debugging,我收到以下消息:

c:\Users\YourUser\WebstormProjects\angularjs-template\app\app.js:6 angular.module('myApp', [ ^ ReferenceError: angular is not defined at Object.<anonymous> (c:\Users\YourUser\WebstormProjects\angularjs-template\app\app.js:6:1) 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.runMain [as _onTimeout] (module.js:497:10) at Timer.listOnTimeout [as ontimeout] (timers.js:112:15) 

在运行中,我收到以下消息:

 c:\Users\YourUser\WebstormProjects\angularjs-template\app\app.js:6 angular.module('myApp', [ ^ ReferenceError: angular is not defined at Object.<anonymous> (c:\Users\YourUser\WebstormProjects\angularjs-template\app\app.js:6:1) 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 

App.js如下

 'use strict'; // Declare app level module which depends on views, and components angular.module('myApp', [ 'ngRoute', 'myApp.view1', 'myApp.view2', 'myApp.version' ]). config(['$routeProvider', function($routeProvider) { $routeProvider.otherwise({redirectTo: '/view1'}); }]); 

是的,在HTML中Angular的顺序如下:

  <script src="bower_components/angular/angular.js"></script> <script src="bower_components/angular-route/angular-route.js"></script> <script src="app.js"></script> 

这很有趣,因为我实际上只是试图运行WebStorm生成的基本模板。

运行configuration有

  Node Interpreter: C:\Program Files\nodejs\node.exe Working directory: C:\Users\YourUser\WebstormProjects\angularjs-template JavaScript file: app\app.js After launch: http://localhost:63342/angularjs-template/app/index.html 

而不是! Angular是未定义的。

我究竟做错了什么?

编辑:确切的输出

 "C:\Program Files (x86)\JetBrains\WebStorm 9.0.1\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" app\app.js c:\Users\Zhuinden\WebstormProjects\angularjs-template\app\app.js:6 angular.module('myApp', [ ^ ReferenceError: angular is not defined at Object.<anonymous> (c:\Users\Zhuinden\WebstormProjects\angularjs-template\app\app.js:6:1) 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 Process finished with exit code 8 

Angular代码不能用node.js运行。 在WebStorm中开始一个新的Angular项目的步骤:

  1. 使用File / New项目创build一个新的Angular项目

  2. 打开内置terminal,运行“npm install”

  3. 右键单击app / index.html,select“debugging” – 您的Angular应用程序将在WebStorm内置服务器上运行

它看起来像你试图在node.js上运行app.js。 我认为在项目模板中应该存在服务器的js文件。

你必须像往常一样运行index.html,而不是app.js。 Algo在项目的根文件夹中可以运行npm start,它将运行带有端口页面的服务器:8000