javascript - Angular:无效的配置对象。 Webpack 已使用与 API 架构不匹配的配置对象进行初始化

标签 javascript node.js angular webpack single-page-application

我的项目工作正常,直到我将整个项目文件夹复制到另一台机器上,这就是我现在在新机器上得到的:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.entry should be one of these:
   function | object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string]
   -> The entry point(s) of the compilation.
   Details:
    * configuration.entry should be an instance of function
      -> A Function returning an entry object, an entry string, an entry array or a promise to these things.
    * configuration.entry['styles'] should be a string.
      -> The string is resolved to a module which is loaded upon startup.
    * configuration.entry['styles'] should not contain the item 'G:\MyProjects\kud2\node_modules\ngx-bootstrap\datepicker\bs-datepicker.css' twice.
    * configuration.entry should be a string.
      -> An entry point without name. The string is resolved to a module which is loaded upon startup.
    * configuration.entry should be an array:
      [non-empty string]
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.entry should be one of these:
   function | object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string]
   -> The entry point(s) of the compilation.
   Details:
    * configuration.entry should be an instance of function
      -> A Function returning an entry object, an entry string, an entry array or a promise to these things.
    * configuration.entry['styles'] should be a string.
      -> The string is resolved to a module which is loaded upon startup.
    * configuration.entry['styles'] should not contain the item 'G:\MyProjects\kud2\node_modules\ngx-bootstrap\datepicker\bs-datepicker.css' twice.
    * configuration.entry should be a string.
      -> An entry point without name. The string is resolved to a module which is loaded upon startup.
    * configuration.entry should be an array:
      [non-empty string]
    at webpack (G:\MyProjects\kud2\node_modules\webpack\lib\webpack.js:31:9)
    at Observable.rxjs_1.Observable.obs [as _subscribe] (G:\MyProjects\kud2\node_modules\@angular-devkit\build-webpack\src\webpack-dev-server\index.js:39:37)
    at Observable._trySubscribe (G:\MyProjects\kud2\node_modules\rxjs\internal\Observable.js:44:25)
    at Observable.subscribe (G:\MyProjects\kud2\node_modules\rxjs\internal\Observable.js:30:22)
    at G:\MyProjects\kud2\node_modules\rxjs\internal\util\subscribeTo.js:22:31
    at Object.subscribeToResult (G:\MyProjects\kud2\node_modules\rxjs\internal\util\subscribeToResult.js:10:45)
    at MergeMapSubscriber._innerSub (G:\MyProjects\kud2\node_modules\rxjs\internal\operators\mergeMap.js:82:29)
    at MergeMapSubscriber._tryNext (G:\MyProjects\kud2\node_modules\rxjs\internal\operators\mergeMap.js:76:14)
    at MergeMapSubscriber._next (G:\MyProjects\kud2\node_modules\rxjs\internal\operators\mergeMap.js:59:18)
    at MergeMapSubscriber.Subscriber.next (G:\MyProjects\kud2\node_modules\rxjs\internal\Subscriber.js:67:18)
    at TapSubscriber._next (G:\MyProjects\kud2\node_modules\rxjs\internal\operators\tap.js:65:26)
    at TapSubscriber.Subscriber.next (G:\MyProjects\kud2\node_modules\rxjs\internal\Subscriber.js:67:18)
    at MergeMapSubscriber.notifyNext (G:\MyProjects\kud2\node_modules\rxjs\internal\operators\mergeMap.js:92:26)
    at InnerSubscriber._next (G:\MyProjects\kud2\node_modules\rxjs\internal\InnerSubscriber.js:28:21)
    at InnerSubscriber.Subscriber.next (G:\MyProjects\kud2\node_modules\rxjs\internal\Subscriber.js:67:18)
    at MergeMapSubscriber.notifyNext (G:\MyProjects\kud2\node_modules\rxjs\internal\operators\mergeMap.js:92:26)

Package.json

{
  "name": "kud2",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "bootstrap": "^3.4.1",
    "core-js": "^2.5.4",
    "ngx-bootstrap": "^4.1.1",
    "rxjs": "~6.3.3",
    "tslib": "^1.9.0",
    "webpack-cli": "^3.3.2",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "~7.3.9",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "~7.2.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.2.2",
    "webpack": "^4.31.0"
  }
}

我尝试过重新安装 webpack 但没有成功。

npm uninstall webpack --save-dev
npm install webpack --save-dev

有什么想法可能导致这种情况吗?

最佳答案

我也遇到了同样的问题,这就是我解决的方法。我在 angular.json 中使用了两种样式

"styles": [
    "./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
    "src/styles.css",
    "node_modules/bootstrap/dist/css/bootstrap.min.css",
    "src/styles.css"

 ],

如您所见,有两个“src/style.css”

新代码

"styles": [
   "./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
   "src/styles.css",
   "node_modules/bootstrap/dist/css/bootstrap.min.css"

],

关于javascript - Angular:无效的配置对象。 Webpack 已使用与 API 架构不匹配的配置对象进行初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56132353/

相关文章:

javascript - 测试 : You will need to wrap any code with asynchronous side-effects in a run 时出现 Ember 错误

javascript - Flow Js - 将文件作为数组上传

javascript - 如何在 JavaScript 中将字符串日期数字转换为日期时间?

node.js - 尽管表和数据库明显存在且配置正确,但仍然执行 Sequelize 'no such table:'

javascript - 重命名填充返回值 Mongoose

javascript - View 上的主干重新绑定(bind)事件

javascript - 如何仅为 POST 请求创建 Node 服务器

angular - 如何以 Angular react 形式访问表单控件和表单组

jquery - http.get 数据并从此数据更改 css Ionic 3

javascript - 无法读取未定义的属性 'request'