我在Angular 4中开发了一个前端应用程序。 我的浏览器控制台出错,应用程序正常,但我想删除此错误:
Uncaught TypeError: Cannot read property 'core' of undefined
at webpackUniversalModuleDefinition (eval at webpackJsonp.../../../../script-loader/addScript.js.module.exports (addScript.js:9), <anonymous>:9:35)
at eval (eval at webpackJsonp.../../../../script-loader/addScript.js.module.exports (addScript.js:9), <anonymous>:10:3)
at eval (<anonymous>)
at webpackJsonp.../../../../script-loader/addScript.js.module.exports (addScript.js:9)
at Object.../../../../script-loader/index.js!../../../../@ng-bootstrap/ng-bootstrap/bundles/ng-bootstrap.js (ng-bootstrap.js?6c12:1)
at __webpack_require__ (bootstrap f869e51aadb3d665a815:54)
at Object.1 (scripts.bundle.js:65)
at __webpack_require__ (bootstrap f869e51aadb3d665a815:54)
at webpackJsonpCallback (bootstrap f869e51aadb3d665a815:25)
at scripts.bundle.js:1
你知道为什么我有这个错误吗?也许你想看看我的部分代码?
这里是我的angular-cli.json
{
"project": {
"version": "1.0.0",
"name": "AIE"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets"
],
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"assets/bootstrap/css/bootstrap.css",
"../node_modules/vis/dist/vis.min.css",
"../node_modules/primeng/resources/themes/omega/theme.css",
"../node_modules/font-awesome/css/font-awesome.min.css",
"../node_modules/primeng/resources/primeng.min.css",
"styles.css"
],
"scripts": [
"../node_modules/@ng-bootstrap/ng-bootstrap/bundles/ng-bootstrap.js",
"../node_modules/chart.js/src/chart.js",
"../node_modules/vis/dist/vis.min.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"prefixInterfaces": false,
"inline": {
"style": false,
"template": false
},
"spec": {
"class": false,
"component": true,
"directive": true,
"module": false,
"pipe": true,
"service": true
}
}
}
我不知道问题是否在这里,所有应用程序都存在此错误。
答案 0 :(得分:3)
问题是您将ng-bootstrap库放在CLI的scripts部分中。删除它,错误应该消失。
从"scripts": []
部分删除以下内容:
“../ node_modules/@ng-bootstrap/ng-bootstrap/bundles/ng-bootstrap.js”,
您最好从组件中的@ng-bootstrap/ng-bootstrap
导入符号。