【发布时间】:2017-08-25 18:55:02
【问题描述】:
我正在尝试在 node.js 中运行一个应用程序,而我以前从未使用过 node,当我在终端中输入 node app.js 时,我收到以下错误消息:
ReferenceError: angular is not defined
at Object.<anonymous> (/Users/michael/Desktop/myapp/app/app.js:20:3)
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:393:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:508:3
我安装了角度。这是错误中提到的 app.js 文件的代码部分:
var app = angular
.module('gbook', ['ui.router', 'uiSwitch', 'LocalStorageModule', 'vsGoogleAutocomplete', 'ngCookies', 'gbook.config', 'gbook.intlTelInput', 'ui.timepicker', 'ngAnimate', 'ngSanitize', 'mgcrea.ngStrap', 'froala', 'ui.bootstrap'])
.config(config)
.run(run);
我在 angular 文件夹下的 index.js 中也有这段代码:
require('./angular');
module.exports = angular;
是我在安装 Angular 时做错了什么,还是其他原因?
【问题讨论】:
-
如果您需要更多信息,请告诉我
-
Angular 是客户端框架,Node 是服务器端。为什么要在节点中运行角度? (可以在支持 Node.js 的情况下运行 Angular 应用程序,但您所做的是不同的,而且似乎是错误的)
-
请检查您的库是否保存在公共文件夹中,以便它们在浏览器中正确加载