Skar
Skar

Reputation: 642

Deploy failed Netlify Vue - Could not resolve

I have a problem with deploying my Vue project on Netlify.

When I manually deploy my page (npm run build in VSC terminal -> drag and drop dist folder on Netlify) it works without any problems. But I want it to deploy automatically when I push new commit in my repo.

When I want to deploy site I get a weird error on Building saying:

Could not resolve ./PcBuilderComponentCardList.vue from src/components/PcBuilderCard.vue.

Why does my build fail?

In my PcBuilderCard component the only import of a component I have is

<script setup>
import PcBuilderComponentCardList from './PcBuilderComponentCardList.vue';

so I don't know what I have to change here... I don't have line ./PcBuilderComponentCardList.vue from src/components/PcBuilderCard.vue anywhere in my code.

Log of failed build:

9:46:42 AM: $ npm run build
9:46:42 AM: > [email protected] build
9:46:42 AM: > vite build
9:46:42 AM: vite v4.4.9 building for production...
9:46:42 AM: transforming...
9:46:46 AM: ✓ 1407 modules transformed.
9:46:46 AM: ✓ built in 3.36s
9:46:46 AM: Could not resolve ./PcBuilderComponentCardList.vue from src/components/PcBuilderCard.vue
9:46:46 AM: file: /opt/build/repo/frontend/vue/src/components/PcBuilderCard.vue
9:46:46 AM: error during build:
9:46:46 AM: RollupError: Could not resolve ./PcBuilderComponentCardList.vue from src/components/PcBuilderCard.vue
9:46:46 AM:     at error (file:///opt/build/repo/frontend/vue/node_modules/rollup/dist/es/shared/node-entry.js:2245:30)
9:46:46 AM:     at ModuleLoader.handleInvalidResolvedId (file:///opt/build/repo/frontend/vue/node_modules/rollup/dist/es/shared/node-entry.js:24736:24)
9:46:46 AM:     at file:///opt/build/repo/frontend/vue/node_modules/rollup/dist/es/shared/node-entry.js:24698:26
9:46:46 AM: ​
9:46:46 AM: build.command failed                                        
9:46:46 AM: ────────────────────────────────────────────────────────────────
9:46:46 AM: ​
9:46:46 AM:   Error message
9:46:46 AM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
9:46:46 AM: ​
9:46:46 AM:   Error location
9:46:46 AM:   In Build command from Netlify app:
9:46:46 AM:   npm run build
9:46:46 AM: ​
9:46:46 AM:   Resolved config
9:46:46 AM:   build:
9:46:46 AM:     base: /opt/build/repo/frontend/vue
9:46:46 AM:     command: npm run build
9:46:46 AM:     commandOrigin: ui
9:46:46 AM:     publish: /opt/build/repo/frontend/vue/dist
9:46:46 AM:     publishOrigin: ui
9:46:47 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
9:46:47 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:46:47 AM: Failing build: Failed to build site
9:46:48 AM: Finished processing build request in 24.241s

These are my build settings:

enter image description here

Upvotes: 1

Views: 288

Answers (1)

init-qy
init-qy

Reputation: 356

Sorry about not have permission to comment, here are some of my suggested attempts.

  1. Make sure your git branch is correct and the source code is the same as your local one.
  2. Make sure correct case spelling for your import.
  3. Try to use absloute path like src/components/PcBuilderComponentCardList.vue

Upvotes: 1

Related Questions