After adding simple assetsMenifest in next.config.js and trying to run npm run build. However, the build fails and does not generate assets-manifest.js.
The build is failing with following output in the console.
> Build error occurred
ValidationError: Invalid schema object. WebpackAssetsManifest has been initialized using a schema object that does not match the API schema.
- schema has an unknown property 'nextOptions'. These properties are valid:
object { enabled?, assets?, output?, replacer?, space?, writeToDisk?, fileExtRegex?, sortManifest?, merge?, publicPath?, contextRelativeKeys?, apply?, customize?, transform?, done?, entrypoints?, entrypointsKey?, entrypointsUseAssets?, integrity?, integrityHashes?, integrityPropertyName? }
-> Webpack Assets Manifest options
at validate (E:\AEM\nextjs-sample-app\node_modules\schema-utils\dist\validate.js:105:11)
at E:\AEM\nextjs-sample-app\node_modules\next-assets-manifest\node_modules\webpack-assets-manifest\src\WebpackAssetsManifest.js:73:7
at SyncHook.eval [as call] (eval at create (E:\AEM\nextjs-sample-app\node_modules\next-assets-manifest\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:7:1)
at SyncHook.lazyCompileHook (E:\AEM\nextjs-sample-app\node_modules\next-assets-manifest\node_modules\tapable\lib\Hook.js:154:20)
at WebpackAssetsManifest.apply (E:\AEM\nextjs-sample-app\node_modules\next-assets-manifest\node_modules\webpack-assets-manifest\src\WebpackAssetsManifest.js:119:29)
at createCompiler (E:\AEM\nextjs-sample-app\node_modules\next\dist\compiled\webpack\bundle5.js:134206:12)
at create (E:\AEM\nextjs-sample-app\node_modules\next\dist\compiled\webpack\bundle5.js:134267:16)
at webpack (E:\AEM\nextjs-sample-app\node_modules\next\dist\compiled\webpack\bundle5.js:134291:32)
at Object.f [as webpack] (E:\AEM\nextjs-sample-app\node_modules\next\dist\compiled\webpack\bundle5.js:89548:16)
at E:\AEM\nextjs-sample-app\node_modules\next\dist\build\compiler.js:31:40 {
errors: [
{
keyword: 'additionalProperties',
dataPath: '',
schemaPath: '#/additionalProperties',
params: [Object],
message: 'should NOT have additional properties',
schema: false,
parentSchema: [Object],
data: [Object]
}
],
schema: {
title: 'Webpack Assets Manifest options schema',
description: 'Webpack Assets Manifest options',
type: 'object',
additionalProperties: false,
properties: {
enabled: [Object],
assets: [Object],
output: [Object],
replacer: [Object],
space: [Object],
writeToDisk: [Object],
fileExtRegex: [Object],
sortManifest: [Object],
merge: [Object],
publicPath: [Object],
contextRelativeKeys: [Object],
apply: [Object],
customize: [Object],
transform: [Object],
done: [Object],
entrypoints: [Object],
entrypointsKey: [Object],
entrypointsUseAssets: [Object],
integrity: [Object],
integrityHashes: [Object],
integrityPropertyName: [Object]
},
definitions: { functionOrNull: [Object] }
},
headerName: 'WebpackAssetsManifest',
baseDataPath: 'schema',
postFormatter: null
}
info - Creating an optimized production build .npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nextjs-sample-app@ build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nextjs-sample-app@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\<my_user>\AppData\Roaming\npm-cache\_logs\2021-12-16T21_04_34_217Z-debug.log
The next.js app is pretty basic. Trying to rum build just after creating new next.js app using npx create-next-app command.
{
"name": "nextjs-sample-app",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"next": "12.0.7",
"next-assets-manifest": "^0.2.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"webpack-assets-manifest": "^5.0.6",
"xmldom": "^0.6.0"
},
"devDependencies": {
"eslint": "8.4.1",
"eslint-config-next": "12.0.7"
}
}
const withAssetsManifest = require("next-assets-manifest");
module.exports = withAssetsManifest({
assetsManifest: {
// https://github.com/webdeveric/webpack-assets-manifest#options-read-the-schema
output: "assets-manifest.json",
},
});