#ERROR Nuxt Build Error: Invalid substitution
7 messages · Page 1 of 1 (latest)
I can see you're encountering a build error with Nuxt. This error is related to an issue with character encoding or file paths during the build process.
The error message indicates there's a problem with the substitution pattern for output file names. This type of error often occurs due to one of several possible issues:
-
Invalid characters in file paths: The error message showing
�(unexpected character) suggests there might be encoding issues in one of your files or dependencies. -
Dependency conflicts: Based on the knowledge sources, this could be related to conflicting versions of dependencies in your Nuxt project, particularly with packages like
ohashwhich appears in multiple versions across several issues. -
Build process interruption: Sometimes this error can occur if you're trying to build while the dev server is still running.
Here are some potential solutions:
-
Stop the dev server before building: As mentioned in one of the issues, "It happens when I try to build locally while the dev server is up. It crashes upon reaching prerendering. Turning off the dev server solved it." Github Issue #29282
-
Clear node_modules and reinstall dependencies:
rm -rf node_modules npm cache clean --force # or yarn cache clean npm install # or yarn install -
Check for file encoding issues: Make sure all your files are properly encoded (UTF-8 without BOM).
-
Update Nuxt and its dependencies: If you're using an older version, updating might resolve the issue as some of these problems have been fixed in newer releases.
If the problem persists, you might want to check if there are any non-JavaScript files being imported without proper plugins, as suggested by the error message in one of the examples: "RollupError: Unexpected character '�' (Note that you need plugins to import files that are not JavaScript)".
Would you be able to share your Nuxt version and any specific actions you were taking when this error occurred?
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@cinder zenith Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@prime seal these are the modules is because I added nuxt seo? modules: ['@uneven delta/ui', '@uneven delta/image', '@uneven deltajs/seo', 'nuxt-gtag', 'nuxt-swiper'],
Let me check the knowledge base for you again. One moment! :books:
Based on your question about modules and Nuxt SEO, I can provide some insights about the module configuration you're showing.
The module list you've shared modules: ['/ui', '/image', 'js/seo', 'nuxt-gtag', 'nuxt-swiper'] appears to have some non-standard path formats that might be causing issues.
In Nuxt, modules should be properly referenced either by:
- Package name (e.g., '@nuxtjs/seo')
- Relative path to your project (e.g., '~/modules/seo.js')
- Array format with options (e.g., ['@nuxtjs/google-analytics', { ua: 'X1234567' }])
The format you're using with paths like '/ui', '/image', and 'js/seo' doesn't follow the standard Nuxt module naming conventions, which could potentially lead to errors during build.
According to the Nuxt documentation:
modules: [
// Using package name
'@nuxtjs/axios',
// Relative to your project srcDir
'~/modules/awesome.js',
// Providing options
['@nuxtjs/google-analytics', { ua: 'X1234567' }],
// Inline definition
function () {}
]
If you're trying to use SEO modules, you should use the official package names. Based on the knowledge sources, there are modules like @nuxtjs/seo that might be what you're looking for.
The build error you experienced in your previous question could be related to these incorrectly formatted module paths. I recommend checking the correct package names for the modules you want to use and updating your configuration accordingly.