gatsbyjs/gatsby · error · Error
Encountered unknown module type: ${module.type}. Please open
Error message
Encountered unknown module type: ${module.type}. Please open an issue. What it means
Thrown from the webpack splitChunks `lib.name` callback when a module that passes the lib-chunk test (>160kb, from node_modules, not CSS) has no `libIdent` method. `libIdent` produces a stable, context-relative identifier used to hash the chunk name; some webpack 5 module types (e.g. raw/asset/external modules) do not implement it. Gatsby treats this as an internal invariant and asks the user to file an issue.
Source
Thrown at packages/gatsby/src/utils/webpack.config.js:694
return FRAMEWORK_BUNDLES_REGEX.test(module.nameForCondition())
},
priority: 40,
// Don't let webpack eliminate this chunk (prevents this chunk from becoming a part of the commons chunk)
enforce: true,
},
// if a module is bigger than 160kb from node_modules we make a separate chunk for it
lib: {
test(module) {
return (
!isCssModule(module) &&
module.size() > 160000 &&
/node_modules[/\\]/.test(module.identifier())
)
},
name(module) {
const hash = crypto.createHash(`sha1`)
if (!module.libIdent) {
throw new Error(
`Encountered unknown module type: ${module.type}. Please open an issue.`
)
}
hash.update(module.libIdent({ context: program.directory }))
return hash.digest(`hex`).substring(0, 8)
},
priority: 30,
minChunks: 1,
reuseExistingChunk: true,
},
commons: {
name: `commons`,
// if a chunk is used on all components we put it in commons (we need at least 2 components)
minChunks: Math.max(componentsCount, 2),
priority: 20,
},View on GitHub (pinned to 8b06340921)
Solutions
- Identify the large dependency (>160kb) recently added and check whether it ships asset/WASM modules.
- Update Gatsby, webpack, and relevant loaders to their latest compatible versions.
- If reproducible, file the issue requested in the message with the dependency list and module.type.
- As a temporary workaround, configure `splitChunks` overrides via `gatsby-node.js` `onCreateWebpackConfig` to exclude the offending module from the lib chunk.
Example fix
// gatsby-node.js workaround: exclude asset modules from lib chunk
exports.onCreateWebpackConfig = ({ stage, actions, getConfig }) => {
const config = getConfig()
if (config.optimization && config.optimization.splitChunks) {
const lib = config.optimization.splitChunks.cacheSets?.lib || config.optimization.splitChunks.cacheGroups?.lib
if (lib && lib.test) {
const orig = lib.test
lib.test = (module) => orig(module) && module.libIdent !== undefined
}
}
actions.replaceWebpackConfig(config)
} Defensive patterns
Strategy: try-catch
Validate before calling
// Defensive name callback that skips modules without libIdent
name(module) {
if (!module.libIdent) return 'fallback-chunk'
const hash = crypto.createHash('sha1')
hash.update(module.libIdent({ context: program.directory }))
return hash.digest('hex').substring(0, 8)
} Prevention
- Keep webpack, loaders, and Gatsby on compatible versions.
- Audit heavy dependencies (>160kb) that ship asset/WASM modules.
- Report the module.type to Gatsby if reproducible.
When it happens
Trigger: A dependency in `node_modules` larger than 160kb ships a module type for which webpack does not provide `libIdent` (e.g. an asset/data/native module surfaced through a loader chain). The `name` callback is invoked during chunk optimization and the guard trips.
Common situations: Adding a heavy dependency (WASM, large data files, native bindings) whose webpack module type lacks `libIdent`; upgrading webpack-related Gatsby internals or a loader that changes the emitted module type; very rarely hit, typically indicates a loader/bundler edge case.
Related errors
- something changed in webpack but I don't know what
- The result of this StaticQuery could not be fetched. This i
- ${err}
- Missing compiler
- Missing required params
AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13).
Data as JSON: /api/errors/82676ef4660b18cb.
Report an issue: GitHub.