NextJs -> 验证错误:配置对象无效。Webpack 已使用与 API 模式不匹配的配置对象进行初始化



所以我刚刚从Next v12升级到v12.2.3,在根目录中创建了一个新的middleware.js文件;纱线开发;得到了这个:

ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration[0].module.rules[5] should be one of these:
["..." | object { assert?, compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }, ...]
-> A rule.
Details:
* configuration[0].module.rules[5].include[0] has an unknown property 'pages'. These properties are valid:
object { and?, not?, or? }
-> Logic operators used in a condition matcher.
* configuration[0].module.rules[5].include[0] has an unknown property 'appDir'. These properties are valid:
object { and?, not?, or? }
-> Logic operators used in a condition matcher.
* configuration[0].module.rules[5].include[0] has an unknown property 'pages'. These properties are valid:
object { and?, not?, or? }
-> Logic operators used in a condition matcher.
* configuration[0].module.rules[5].include[0] has an unknown property 'appDir'. These properties are valid:
object { and?, not?, or? }
-> Logic operators used in a condition matcher.
- configuration[1].module.rules[4] should be one of these:
["..." | object { assert?, compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }, ...]
-> A rule.
Details:
* configuration[1].module.rules[4].include[0] has an unknown property 'pages'. These properties are valid:
object { and?, not?, or? }
-> Logic operators used in a condition matcher.
* configuration[1].module.rules[4].include[0] has an unknown property 'appDir'. These properties are valid:
object { and?, not?, or? }
-> Logic operators used in a condition matcher.
* configuration[1].module.rules[4].include[0] has an unknown property 'pages'. These properties are valid:
object { and?, not?, or? }
-> Logic operators used in a condition matcher.
* configuration[1].module.rules[4].include[0] has an unknown property 'appDir'. These properties are valid:
object { and?, not?, or? }
-> Logic operators used in a condition matcher.
- configuration[2].module.rules[8] should be one of these:
["..." | object { assert?, compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }, ...]
-> A rule.
Details:
* configuration[2].module.rules[8].include[0] has an unknown property 'pages'. These properties are valid:
object { and?, not?, or? }
-> Logic operators used in a condition matcher.
* configuration[2].module.rules[8].include[0] has an unknown property 'appDir'. These properties are valid:
object { and?, not?, or? }
-> Logic operators used in a condition matcher.
* configuration[2].module.rules[8].include[0] has an unknown property 'pages'. These properties are valid:
object { and?, not?, or? }
-> Logic operators used in a condition matcher.
* configuration[2].module.rules[8].include[0] has an unknown property 'appDir'. These properties are valid:
object { and?, not?, or? }
-> Logic operators used in a condition matcher.
at validate (D:GitHubMy_Projectnode_modulesnextdistcompiledschema-utils3index.js:1:150815)
at validateSchema (D:GitHubMy_Projectnode_modulesnextdistcompiledwebpackbundle5.js:139253:2)
at create (D:GitHubMy_Projectnode_modulesnextdistcompiledwebpackbundle5.js:142750:24)
at webpack (D:GitHubMy_Projectnode_modulesnextdistcompiledwebpackbundle5.js:142797:32)
at Object.f [as webpack] (D:GitHubMy_Projectnode_modulesnextdistcompiledwebpackbundle5.js:97275:16)
at HotReloader.start (D:GitHubMy_Projectsnode_modulesnextdistserverdevhot-reloader.js:430:45)
at async DevServer.prepare (D:GitHubMy_Projectnode_modulesnextdistserverdevnext-dev-server.js:334:9)
at async D:GitHubMy_Projectnode_modulesnextdistclinext-dev.js:147:9 {
errors: [
{
keyword: 'oneOf',
dataPath: '[0].module.rules',
schemaPath: '#/properties/rules/oneOf',
params: [Object],
message: 'should match exactly one schema in oneOf',
schema: [Array],
parentSchema: [Object],
data: [Array],
children: [Array]
},
{
keyword: 'oneOf',
dataPath: '[1].module.rules',
schemaPath: '#/properties/rules/oneOf',
params: [Object],
message: 'should match exactly one schema in oneOf',
schema: [Array],
parentSchema: [Object],
data: [Array],
children: [Array]
},
{
keyword: 'oneOf',
dataPath: '[2].module.rules',
schemaPath: '#/properties/rules/oneOf',
params: [Object],
message: 'should match exactly one schema in oneOf',
schema: [Array],
parentSchema: [Object],
data: [Array],
children: [Array]
}
],
schema: {
definitions: {
Amd: [Object],
AssetFilterItemTypes: [Object],
AssetFilterTypes: [Object],
AssetGeneratorDataUrl: [Object],
AssetGeneratorDataUrlFunction: [Object],
AssetGeneratorDataUrlOptions: [Object],
AssetGeneratorOptions: [Object],
AssetInlineGeneratorOptions: [Object],
AssetModuleFilename: [Object],
AssetModuleOutputPath: [Object],
AssetParserDataUrlFunction: [Object],
AssetParserDataUrlOptions: [Object],
AssetParserOptions: [Object],
AssetResourceGeneratorOptions: [Object],
AuxiliaryComment: [Object],
Bail: [Object],
CacheOptions: [Object],
CacheOptionsNormalized: [Object],
Charset: [Object],
ChunkFilename: [Object],
ChunkFormat: [Object],
ChunkLoadTimeout: [Object],
ChunkLoading: [Object],
ChunkLoadingGlobal: [Object],
ChunkLoadingType: [Object],
Clean: [Object],
CleanOptions: [Object],
CompareBeforeEmit: [Object],
Context: [Object],
CrossOriginLoading: [Object],
CssChunkFilename: [Object],
CssExperimentOptions: [Object],
CssFilename: [Object],
CssGeneratorOptions: [Object],
CssParserOptions: [Object],
Dependencies: [Object],
DevServer: [Object],
DevTool: [Object],
DevtoolFallbackModuleFilenameTemplate: [Object],
DevtoolModuleFilenameTemplate: [Object],
DevtoolNamespace: [Object],
EmptyGeneratorOptions: [Object],
EmptyParserOptions: [Object],
EnabledChunkLoadingTypes: [Object],
EnabledLibraryTypes: [Object],
EnabledWasmLoadingTypes: [Object],
Entry: [Object],
EntryDescription: [Object],
EntryDescriptionNormalized: [Object],
EntryDynamic: [Object],
EntryDynamicNormalized: [Object],
EntryFilename: [Object],
EntryItem: [Object],
EntryNormalized: [Object],
EntryObject: [Object],
EntryRuntime: [Object],
EntryStatic: [Object],
EntryStaticNormalized: [Object],
EntryUnnamed: [Object],
Environment: [Object],
Experiments: [Object],
ExperimentsCommon: [Object],
ExperimentsNormalized: [Object],
ExternalItem: [Object],
ExternalItemFunctionData: [Object],
ExternalItemValue: [Object],
Externals: [Object],
ExternalsPresets: [Object],
ExternalsType: [Object],
FileCacheOptions: [Object],
Filename: [Object],
FilenameTemplate: [Object],
FilterItemTypes: [Object],
FilterTypes: [Object],
GeneratorOptionsByModuleType: [Object],
GlobalObject: [Object],
HashDigest: [Object],
HashDigestLength: [Object],
HashFunction: [Object],
HashSalt: [Object],
HotUpdateChunkFilename: [Object],
HotUpdateGlobal: [Object],
HotUpdateMainFilename: [Object],
HttpUriAllowedUris: [Object],
HttpUriOptions: [Object],
HttpUriOptionsAllowedUris: [Object],
IgnoreWarnings: [Object],
IgnoreWarningsNormalized: [Object],
Iife: [Object],
ImportFunctionName: [Object],
ImportMetaName: [Object],
InfrastructureLogging: [Object],
JavascriptParserOptions: [Object],
Layer: [Object],
LazyCompilationDefaultBackendOptions: [Object],
LazyCompilationOptions: [Object],
Library: [Object],
LibraryCustomUmdCommentObject: [Object],
LibraryCustomUmdObject: [Object],
LibraryExport: [Object],
LibraryName: [Object],
LibraryOptions: [Object],
LibraryType: [Object],
Loader: [Object],
MemoryCacheOptions: [Object],
Mode: [Object],
ModuleFilterItemTypes: [Object],
ModuleFilterTypes: [Object],
ModuleOptions: [Object],
ModuleOptionsNormalized: [Object],
Name: [Object],
NoParse: [Object],
Node: [Object],
NodeOptions: [Object],
Optimization: [Object],
OptimizationRuntimeChunk: [Object],
OptimizationRuntimeChunkNormalized: [Object],
OptimizationSplitChunksCacheGroup: [Object],
OptimizationSplitChunksGetCacheGroups: [Object],
OptimizationSplitChunksOptions: [Object],
OptimizationSplitChunksSizes: [Object],
Output: [Object],
OutputModule: [Object],
OutputNormalized: [Object],
Parallelism: [Object],
ParserOptionsByModuleType: [Object],
Path: [Object],
Pathinfo: [Object],
Performance: [Object],
PerformanceOptions: [Object],
Plugins: [Object],
Profile: [Object],
PublicPath: [Object],
RawPublicPath: [Object],
RecordsInputPath: [Object],
RecordsOutputPath: [Object],
RecordsPath: [Object],
Resolve: [Object],
ResolveAlias: [Object],
ResolveLoader: [Object],
ResolveOptions: [Object],
ResolvePluginInstance: [Object],
RuleSetCondition: [Object],
RuleSetConditionAbsolute: [Object],
RuleSetConditionOrConditions: [Object],
RuleSetConditionOrConditionsAbsolute: [Object],
RuleSetConditions: [Object],
RuleSetConditionsAbsolute: [Object],
RuleSetLoader: [Object],
RuleSetLoaderOptions: [Object],
RuleSetLogicalConditions: [Object],
RuleSetLogicalConditionsAbsolute: [Object],
RuleSetRule: [Object],
RuleSetRules: [Object],
RuleSetUse: [Object],
RuleSetUseItem: [Object],
ScriptType: [Object],
SnapshotOptions: [Object],
SourceMapFilename: [Object],
SourcePrefix: [Object],
StatsOptions: [Object],
StatsValue: [Object],
StrictModuleErrorHandling: [Object],
StrictModuleExceptionHandling: [Object],
Target: [Object],
TrustedTypes: [Object],
UmdNamedDefine: [Object],
UniqueName: [Object],
WarningFilterItemTypes: [Object],
WarningFilterTypes: [Object],
WasmLoading: [Object],
WasmLoadingType: [Object],
Watch: [Object],
WatchOptions: [Object],
WebassemblyModuleFilename: [Object],
WebpackOptionsNormalized: [Object],
WebpackPluginFunction: [Object],
WebpackPluginInstance: [Object]
},
title: 'WebpackOptions',
description: 'Options object as provided by the user.',
type: 'object',
additionalProperties: false,
properties: {
amd: [Object],
bail: [Object],
cache: [Object],
context: [Object],
dependencies: [Object],
devServer: [Object],
devtool: [Object],
entry: [Object],
experiments: [Object],
externals: [Object],
externalsPresets: [Object],
externalsType: [Object],
ignoreWarnings: [Object],
infrastructureLogging: [Object],
loader: [Object],
mode: [Object],
module: [Object],
name: [Object],
node: [Object],
optimization: [Object],
output: [Object],
parallelism: [Object],
performance: [Object],
plugins: [Object],
profile: [Object],
recordsInputPath: [Object],
recordsOutputPath: [Object],
recordsPath: [Object],
resolve: [Object],
resolveLoader: [Object],
snapshot: [Object],
stats: [Object],
target: [Object],
watch: [Object],
watchOptions: [Object]
}
},
headerName: 'Webpack',
baseDataPath: 'configuration',
postFormatter: [Function: postFormatter]
}
error Command failed with exit code 1.

我不知道为什么会发生这种情况,这意味着什么,也不知道如何修复它,但现在我甚至无法恢复到v12并运行任何东西!我没有接触任何webpack的东西,我没有任何webpack配置文件,所以我不知道该怎么办。这是我的下一个config.js文件:

const { withSuperjson } = require('next-superjson')

module.exports = withSuperjson()({
images: {
domains: [`${process.env.S3_UPLOAD_BUCKET}.s3.amazonaws.com`],
formats: ['image/avif', 'image/webp'],
},
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},

});

我已经尝试删除。下一个文件夹,我已经删除了节点模块,我已经恢复到另一个分支,但它仍然不起作用!请帮忙。

我刚刚将next-superjson从0.0.2更新到0.0.4,它似乎再次运行,phew。我更新了superjson,但最初没有更新next-superjson,但没有成功。

最新更新