【问题标题】:Stuck at [$injector:nomod] Module 'app' is not available卡在 [$injector:nomod] 模块 'app' 不可用
【发布时间】:2017-06-09 11:48:26
【问题描述】:

我在尝试设置我的新应用时似乎有点卡住了。

我试过了:

import angular from 'angular';
var myApp = angular.module('myApp', []);

我试过了:

const angular = require('angular');
var myApp = angular.module('myApp', []);

我还在继续

Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.6.4/$injector/nomod?p0=app
    at eval (eval at <anonymous> (http://localhost:8080/app.bundle.js:322:1), 

我已经用 npm 安装了 angular,这是来自我的 package.json

  "dependencies": {
    "angular": "^1.5.0",
    "angular-route": "^1.6.4",
    "bootstrap": "^3.3.7"
  },

有什么想法吗?

【问题讨论】:

  • 您的模块名称是 myApp 而不是 app 只需检查您在 ng-app 指令中使用了什么

标签: angularjs node.js


【解决方案1】:

正如错误所说

Error: [$injector:nomod] Module 'app' is not available!

在您尝试使用的应用程序中的某处 ng-app='app' ,将其重命名为 ng-app='myApp'

【讨论】:

  • 到目前为止我还没有完成。我尝试重新安装 Angular,现在我得到了这个:Module not found: Error: Can't resolve 'angular' - @ multi (webpack)-dev-server/client?http://localhost:8081 ./app/main/app.js
  • 会不会是 webpack 里的东西?我不太了解它是如何工作的。
  • 尝试使用 npm install --save @angular
  • 不幸的是我仍然收到错误。我截取了我的终端和错误日志的屏幕截图。 db.tt/gom0eDAIIU我的app.js只有一行:import angular from 'angular';
  • 在你拥有的所有文件中搜索'''app'
猜你喜欢
  • 2016-07-03
  • 1970-01-01
  • 2015-01-23
  • 1970-01-01
  • 2023-04-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多