N
Nuxt4mo ago
WiFi Plug

svg logo

I tried to make a component and paste my svg logo inside the template but i get this error "plugin:vite:vue] Tags with side effect (<script> and <style>) are ignored in client component templates." my svg logo also has whitespace around the edges, what's recommended to clean this up to display my logo svg nicely
8 Replies
kapa.ai
kapa.ai4mo ago
Hi @WiFi Plug. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error message you’re seeing, Tags with side effect (<script> and <style>) are ignored in client component templates., typically occurs if you paste an entire SVG file—including its <script> or <style> tags—directly into a Vue/Nuxt component’s template. In Nuxt, only the SVG markup (the <svg>...</svg>) should be placed inside the template. Remove any <script> or <style> tags from the SVG before using it in your component. How to use your SVG logo in a Nuxt component: 1. Clean the SVG:
- Open your SVG file in a text editor. - Remove any <script> and <style> tags. - Only keep the <svg>...</svg> markup. 2. Remove whitespace around the SVG:
- Check the viewBox attribute in your SVG. If there’s extra space, you can edit the SVG in a vector editor (like Figma, Illustrator, or Inkscape) to crop the canvas tightly around your logo. - Alternatively, you can manually adjust the viewBox values to remove unwanted whitespace. 3. Paste the cleaned SVG into your component:
<template>
<!-- Paste your cleaned SVG here -->
<svg ...>...</svg>
</template>

<template>
<!-- Paste your cleaned SVG here -->
<svg ...>...</svg>
</template>

Alternative: Use nuxt-svgo for auto-import and optimization
If you want to manage SVGs as components and optimize them automatically, you can use the nuxt-svgo module. Place your SVGs in a directory (e.g., ~/assets/svg/), configure autoImportPath, and use them as components without manual imports. This also helps with cleaning up unnecessary attributes and whitespace in your SVGs. See the example:
// nuxt.config.ts
svgo: { autoImportPath: '~/assets/svg/' }
// nuxt.config.ts
svgo: { autoImportPath: '~/assets/svg/' }
Then use your SVG as a component:
<template>
<SvgoLogo class="w-7 inline" />
</template>
<template>
<SvgoLogo class="w-7 inline" />
</template>
No need to import it manually; the module handles it for you. This approach is confirmed to work and helps keep your SVGs clean and optimized using the nuxt-svgo module, SVGs are not being loaded or "found". Summary:
- Remove <script> and <style> from your SVG before pasting. - Adjust the viewBox to remove whitespace. - For best results and easier management, consider using the nuxt-svgo module. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@679734274840330384> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
WiFi Plug
WiFi PlugOP4mo ago
@kapa.ai how do i make svgo remove the whitespace in my svg? and it seems to be adding margin at the bottom?
kapa.ai
kapa.ai4mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I'm sorry, but the knowledge sources do not contain explicit information about configuring SVGO (or the nuxt-svgo module) to automatically remove whitespace or margins from SVGs. The available documentation confirms that nuxt-svgo can auto-import and optimize SVGs, but it does not detail specific SVGO configuration options for trimming whitespace or addressing unwanted margins at the bottom of SVGs. For advanced SVG cleanup, you may need to manually adjust the SVG's viewBox or use a vector editor before importing, as the module's default behavior is not described in detail regarding whitespace removal using the nuxt-svgo module, SVGs are not being loaded or "found". ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@679734274840330384> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
WiFi Plug
WiFi PlugOP4mo ago
@kapa.ai after installing this module and trying to deploy to render i now get this error? "==> Running 'node .output/server/index.mjs' node:internal/modules/esm/resolve:283 throw new ERR_MODULE_NOT_FOUND( ^ Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/render/project/src/.output/server/node_modules/vue/server-renderer/index.mjs' imported from /opt/render/project/src/.output/server/index.mjs at finalizeResolution (node:internal/modules/esm/resolve:283:11) at moduleResolve (node:internal/modules/esm/resolve:952:10) at defaultResolve (node:internal/modules/esm/resolve:1188:11) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:642:12) at #cachedDefaultResolve (node:internal/modules/esm/loader:591:25) at ModuleLoader.resolve (node:internal/modules/esm/loader:574:38) at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:236:38) at ModuleJob._link (node:internal/modules/esm/module_job:130:49) { code: 'ERR_MODULE_NOT_FOUND', url: 'file:///opt/render/project/src/.output/server/node_modules/vue/server-renderer/index.mjs' } Node.js v20.19.2"
kapa.ai
kapa.ai4mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- The error you are seeing:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/render/project/src/.output/server/node_modules/vue/server-renderer/index.mjs' imported from /opt/render/project/src/.output/server/index.mjs
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/opt/render/project/src/.output/server/node_modules/vue/server-renderer/index.mjs' imported from /opt/render/project/src/.output/server/index.mjs
indicates that the Nuxt server build is trying to import the vue/server-renderer module, but it cannot find it in the expected location inside .output/server/node_modules. Based on the knowledge sources, this type of error often happens when: - Some dependencies are only listed in devDependencies instead of dependencies, so they are not installed in the production environment. - The build process is not run in the production environment, or the output is copied from a different environment where dependencies differ. - The deployment process does not include all necessary files or dependencies in the final build output. Recommended steps (based on similar issues and solutions): 1. Move all required dependencies to dependencies:
Make sure that vue, @nuxt/*, and any other runtime dependencies are listed in the dependencies section of your package.json, not just in devDependencies. This ensures they are installed in production environments like Render. This step was crucial in resolving similar deployment issues on other platforms Deploy Nuxt3 to AppEngine Standard or Felxible Environment Part 2. 2. Reinstall dependencies and rebuild:
- Delete node_modules and any lock files (package-lock.json, yarn.lock, or pnpm-lock.yaml). - Run a fresh install (npm install or yarn install). - Rebuild your project (nuxi build or npm run build). 3. Ensure the build step runs on Render:
Make sure your Render build command actually runs the Nuxt build process and does not just copy files from your local machine. The .output directory and all required node modules must be present in the deployed environment. 4. Check for missing modules in .output:
If you are using custom modules or plugins, ensure they are bundled correctly and available in the .output directory. If you follow these steps and the error persists, double-check your deployment logs to ensure that all dependencies are being installed and that the build step completes successfully before the server starts. If you need more specific guidance, please provide your package.json and the exact build and start commands used on Render. --- Summary:
This error is most likely due to missing runtime dependencies in production. Move all required packages to dependencies, reinstall, and rebuild. This approach has resolved similar issues for other Nuxt 3 deployments Deploy Nuxt3 to AppEngine Standard or Felxible Environment Part 2. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@679734274840330384> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?