我再次发现这个错误,上次我已修复,但不知道这是如何修复但又一次发生。
我安装了ngstorage模块并且projecr在开发中运行正常(gulp clean serve
)但是当它进入生产阶段(gulp serve:dist
)时,它执行良好但是主页面是空白的并且控制台中有错误
未捕获错误:[$ injector:modulerr]无法实例化模块应用 由于:错误:[$ injector:modulerr]无法实例化模块 ngStorage由于:错误:[$ injector:nomod]模块' ngStorage'不是 可以!您要么错误拼写了模块名称,要么忘记加载它。 如果注册模块,请确保将依赖项指定为 第二个论点。 http://errors.angularjs.org/1.5.8/ $注射器/ NOMOD?P0 = ngStorage
虽然我已经检查过它安装了但是有人可以建议问题是什么以及如何解决这个问题?这是我的bower.json
{
"name": "project",
"version": "0.1.1",
"dependencies": {
"angular-animate": "1.5.8",
"angular-touch": "~1.5.0",
"angular-sanitize": "~1.5.0",
"angular-messages": "~1.5.0",
"angular-aria": "~1.5.0",
"jquery": "~2.1.4",
"angular-resource": "~1.5.0",
"angular-ui-router": "~0.2.15",
"bootstrap": "~3.3.6",
"angular-bootstrap": "~1.1.2",
"angular-toastr": "~2.0.0",
"moment": "~2.13.0",
"animate.css": "~3.4.0",
"angular": "~1.5.0",
"ng-table": "^1.0.0",
"pace": "~1.0.2",
"metisMenu": "~2.0.2",
"fontawesome": "~4.5.0",
"roboto-fontface": "^0.7.0",
"angular-ui-validate": "^1.2.2",
"ng-stomp": "^0.2.0",
"angular-scrollable-table": "^1.1.1",
"aws-sdk": "aws-sdk-js#^2.7.7",
"ng-file-upload": "^12.2.13",
"angular-recaptcha": "^4.0.3",
"ng-csv": "^0.3.6",
"ngstorage": "^0.3.11",
"intl-tel-input": "5.1.7",
"international-phone-number": "^0.0.16",
"angular-chart.js": "^1.1.1"
},
"devDependencies": {
"angular-mocks": "1.5.8"
},
"overrides": {
"bootstrap": {
"main": [
"less/bootstrap.less",
"dist/fonts/glyphicons-halflings-regular.eot",
"dist/fonts/glyphicons-halflings-regular.svg",
"dist/fonts/glyphicons-halflings-regular.ttf",
"dist/fonts/glyphicons-halflings-regular.woff",
"dist/fonts/glyphicons-halflings-regular.woff2"
]
},
"fontawesome": {
"main": [
"less/font-awesome.less",
"fonts/fontawesome-webfont.eot",
"fonts/fontawesome-webfont.svg",
"fonts/fontawesome-webfont.ttf",
"fonts/fontawesome-webfont.woff",
"fonts/fontawesome-webfont.woff2"
]
},
"roboto-fontface": {
"main": [
"css/roboto/less/roboto-fontface.less"
]
},
"chart.js": {
"main": [
"dist/Chart.bundle.min.js"
]
}
},
"resolutions": {
"jquery": "~2.1.4",
"angular": "1.5.8"
},
"description": "Project Manager On-Premise",
"main": "",
"homepage": "index.html",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
我认为存在与stmop相关的问题,或者我正在使用broswer-sync,这可能是原因但无法确定。
答案 0 :(得分:1)
问题是图书馆的一个 - 其中包括 - 在其主要的js文件中缺少分号
原因:
我在我的项目中使用ng-stomp并使用bower install
安装了此库,当我运行gulp dist:serve
时,它缩小了主 bower.json中提到的所有文件文件,它读取 bower_components / ng-stomp / package.json ,其中主文件位置为"main": "src/ng-stomp.js"
,此文件最后缺少分号,以便下一个js库(ngStorage)它是缩小的,它不会被它的解析器识别,它会抛出错误。
解决方案:
通过在 bower.json 覆盖块中编写以下代码来覆盖主文件(添加 ng-stomp.min.js 最后有分号)
"ng-stomp": {
"main": [
"dist/ng-stmop.min.js"
]
}
希望它可以帮助某人