Angular 误差:已使用与API方案不匹配的配置对象初始化Webpack

7rtdyuoh  于 2022-11-13  发布在  Webpack
关注(0)|答案(5)|浏览(205)

I'm having this error using angular 7, just started today and idk really what's going on here.
I tried update, remove and install all packages again, but no luck.
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 { : 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 'C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\angular-bootstrap-md\scss\mdb-free.scss' 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 { : 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 'C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\angular-bootstrap-md\scss\mdb-free.scss' 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 (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\webpack\lib\webpack.js:31:9) at Observable.rxjs_1.Observable.obs [as _subscribe] (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules@angular-devkit\build-webpack\src\webpack-dev-server\index.js:37:37) at Observable._trySubscribe (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\Observable.js:44:25) at Observable.subscribe (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\Observable.js:30:22) at C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\util\subscribeTo.js:22:31 at Object.subscribeToResult (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\util\subscribeToResult.js:10:45) at MergeMapSubscriber._innerSub (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\operators\mergeMap.js:82:29) at MergeMapSubscriber._tryNext (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\operators\mergeMap.js:76:14) at MergeMapSubscriber._next (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\operators\mergeMap.js:59:18) at MergeMapSubscriber.Subscriber.next (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\Subscriber.js:67:18) at TapSubscriber._next (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\operators\tap.js:65:26) at TapSubscriber.Subscriber.next (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\Subscriber.js:67:18) at MergeMapSubscriber.notifyNext (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\operators\mergeMap.js:92:26) at InnerSubscriber._next (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\InnerSubscriber.js:28:21) at InnerSubscriber.Subscriber.next (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\Subscriber.js:67:18) at MergeMapSubscriber.notifyNext (C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\rxjs\internal\operators\mergeMap.js:92:26)

68bkxrlz

68bkxrlz1#

检查您的angular.json文件,如果有重复的CSS文件!有时当您安装依赖项时,他们会添加已经存在于angular.json文件中的CSS文件。

g6ll5ycj

g6ll5ycj2#

安装最新版本的webpack对我来说很有效,版本4.29.6,带Angular 7.2.11

lbsnaicq

lbsnaicq3#

我最近在一个已经有引导程序的Angular Visual Studio 2019项目中遇到了这种情况,在安装了ngx-bootstrap之后。进一步搜索错误,我发现:

已使用与API架构不匹配的配置对象初始化Webpack。- configuration.entry ['styles']不应包含项目“...\源\repos...\客户端应用程序\节点模块\引导\分发\css\引导.min.css”两次。

而在angular.json中我有:

"styles": [
          "./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
          "./node_modules/bootstrap/dist/css/bootstrap.min.css",
          "node_modules/bootstrap/dist/css/bootstrap.min.css",
          "src/styles.css"
        ],

我可以通过删除其中一个重复的bootstrap条目来修复此问题:

"styles": [
          "./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
          "node_modules/bootstrap/dist/css/bootstrap.min.css",
          "src/styles.css"
        ],

然后我的项目又开始运行了。这里的关键是检查错误消息,看看配置中有什么错误,如果指定了的话。
举个例子,在最初的帖子中我们看到了非常相似的内容:

  • 项目['样式']不应该包含项目'C:\Users\smoreira\Documents\projetos\oficiais\doc-translator-front\node_modules\angular-bootstrap-md\scss\mdb-free.scss'两次。
fzwojiic

fzwojiic4#

正如错误所说
节点模块\Angular 引导程序-md\scss\mdb-free.scss'两次
这意味着相同的样式在"styles":标签中重复了两次,所以你需要删除一个。在你的angular.json文件中检查一下。

ccrfmcuu

ccrfmcuu5#

解决方案是重新安装节点并创建一个新的角项目。

相关问题