question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nuxt build cant find files

See original GitHub issue

Environment

Nuxt project info: 00:24:59


  • Operating System: Windows
  • Node Version: v14.17.0
  • Nuxt Version: 3-3.0.0-27235973.ad4e2e9
  • Package Manager: npm
  • Bundler: Webpack
  • User Config: debug, srcDir, ssr, head, components, buildModules, router, modules, build
  • Runtime Modules: -
  • Build Modules: -

Describe the bug

nuxt build

[vite] Internal server error: Failed to resolve import “icons/logo.svg” from “src\client\components\main\Header.vue”. Does the file exist?

nuxt config have srcDir: ‘src/client/’,

Reproduction

in component im use img class=“h-32 w-32 mx-auto” src=“/icons/logo.svg” alt=“Workflow”

Additional context

dev mode works fine builld cant find files.

Logs

ERROR  00:20:28 [vite] Internal server error: Failed to resolve import "icons/logo.svg" from "src\client\components\main\Header.vue". Does the file exist?
  Plugin: vite:import-analysis
  File: C:/Users/Andy/Desktop/nuxt3/udc/src/client/components/main/Header.vue
  1  |  import { h } from 'vue';const _sfc_main = {}
  2  |  import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue"
  3  |  import _imports_0 from 'icons/logo.svg'
     |                          ^
  4  |

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
HenrijsScommented, Oct 14, 2021

@danielroe https://codesandbox.io/s/awesome-herschel-8n7pq?file=/src/client/app.vue

Remember: It works in dev mode. Doesn’t work when building!

0reactions
arb85commented, Jan 10, 2022

@HenrijsS Maybe your question is asked with the updated documentation:

https://v3.nuxtjs.org/docs/directory-structure/nuxt.config#rootdir

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuxt build directory
Inside the directory you can find automatically generated files when using nuxt dev or your build artifacts when using nuxt build.
Read more >
Nuxt.js After npm run generate cannot find files - Stack Overflow
I try to upload dist folder to my ftp but there is too same… here is my nuxt.config file const pkg = require('./package')...
Read more >
Understanding folder / file structure in Nuxt | by Liam Hall
Starting a new Nuxt project for the first time may seem daunting, understanding the basic folder structure and each folders unique function ...
Read more >
Nuxt js Error Couldn't find a pages directory
I am getting Error: Couldn't find a pages directory in D:\sample. Please create one under the project root how do I access pages...
Read more >
Folders & Files - Academind
In a new Nuxt.js project, you see many (empty) folders and files. Nuxt.js allows you to build Vue apps that are mainly configured...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found