Build failing with Rollup Error - Command failed with exit code 1 - Could not resolve `.x/y/z/component`

Hello Friendly Forum Fiends :wave:

I hope someone might be able to help a Netlify-Newbie :innocent:
I am trying to follow community guidelines best I can, please correct me if I have done something incorrectly.

Brief Description of the project

So I have built this relatively simple e-commerce portfolio project and I cannot seem to get it to deploy/build through Netlify.
This is React project built with Vite ,
using FireBase for user Authentication and FireStore for very basic database.
using Stripe API - I have created the necessary Environment Variables, added through the app.Netlify web page (using .env when running locally)

Details are as follows:

Netlify site name:
https://candid-rabanadas-90d3ef.netlify.app/

GitHub Repo: (main branch)
https://github.com/DevonGifford/Ecommerce_Showcase

Things I have tried:

  • I have tried the following build commands: (clearing cache each time)
  1. CI= npm run build
  2. npm run build
  3. vite build
  • Initially I had naming convention issues and after checking the forum and fixing, I am now getting stuck again

Finally, the app is working when I run locally on my machine with both

  1. npm run dev
  2. netlify dev

Also tried to host/deploy directly from the CLI tool however facing the same error of not being able to resolve this same component.

Build settings screenshot

image

Please see below the FULL build log

> 12:36:56 AM: build-image version: 3b96229e32b19cdf63f20dc1fc9331cd240c2d01 (focal)
> 12:36:56 AM: buildbot version: 3b96229e32b19cdf63f20dc1fc9331cd240c2d01
> 12:36:56 AM: Building without cache
> 12:36:56 AM: Starting to prepare the repo for build
> 12:36:56 AM: No cached dependencies found. Cloning fresh repo
> 12:36:56 AM: git clone --filter=blob:none https://github.com/DevonGifford/Ecommerce_Showcase
> 12:36:57 AM: Preparing Git Reference refs/heads/main
> 12:36:58 AM: Starting to install dependencies
> 12:36:58 AM: Python version set to 3.8
> 12:36:59 AM: Attempting Ruby version 2.7.2, read from environment
> 12:36:59 AM: Using Ruby version 2.7.2
> 12:37:00 AM: Started restoring cached go cache
> 12:37:00 AM: Finished restoring cached go cache
> 12:37:00 AM: go version go1.19.10 linux/amd64
> 12:37:00 AM: Using PHP version 8.0
> 12:37:01 AM: v18.16.0 is already installed.
> 12:37:01 AM: Now using node v18.16.0 (npm v9.5.1)
> 12:37:01 AM: Enabling Node.js Corepack
> 12:37:01 AM: Started restoring cached build plugins
> 12:37:01 AM: Finished restoring cached build plugins
> 12:37:01 AM: Started restoring cached corepack dependencies
> 12:37:01 AM: Finished restoring cached corepack dependencies
> 12:37:01 AM: No npm workspaces detected
> 12:37:01 AM: Started restoring cached node modules
> 12:37:01 AM: Finished restoring cached node modules
> 12:37:02 AM: Installing npm packages using npm version 9.5.1
> 12:37:08 AM: added 428 packages, and audited 429 packages in 6s
> 12:37:08 AM: 105 packages are looking for funding
> 12:37:08 AM:   run `npm fund` for details
> 12:37:08 AM: found 0 vulnerabilities
> 12:37:08 AM: npm packages installed
> 12:37:09 AM: Install dependencies script success
> 12:37:09 AM: Starting build script
> 12:37:09 AM: Detected 1 framework(s)
> 12:37:09 AM: vite at version 4.3.9
> 12:37:09 AM: Section completed: initializing
> 12:37:11 AM: ​
> 12:37:11 AM: Netlify Build                                                 
> 12:37:11 AM: ────────────────────────────────────────────────────────────────
> 12:37:11 AM: ​
> 12:37:11 AM: ❯ Version
> 12:37:11 AM:   @netlify/build 29.12.1
> 12:37:11 AM: ​
> 12:37:11 AM: ❯ Flags
> 12:37:11 AM:   baseRelDir: true
> 12:37:11 AM:   buildId: 6488ef865718442e1f45fd50
> 12:37:11 AM:   deployId: 6488ef865718442e1f45fd52
> 12:37:11 AM: ​
> 12:37:11 AM: ❯ Current directory
> 12:37:11 AM:   /opt/build/repo
> 12:37:11 AM: ​
> 12:37:11 AM: ❯ Config file
> 12:37:11 AM:   No config file was defined: using default values.
> 12:37:11 AM: ​
> 12:37:11 AM: ❯ Context
> 12:37:11 AM:   production
> 12:37:11 AM: ​
> 12:37:11 AM: Build command from Netlify app                                
> 12:37:11 AM: ────────────────────────────────────────────────────────────────
> 12:37:11 AM: ​
> 12:37:11 AM: $ vite build
> 12:37:11 AM: vite v4.3.9 building for production...
> 12:37:11 AM: transforming...
> 12:37:13 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
> 12:37:12 AM: βœ“ 78 modules transformed.
> 12:37:12 AM: βœ“ built in 680ms
> 12:37:12 AM: Could not resolve ../../components/front-splash/front-splash.component from src/routes/home/home.component.jsx
> 12:37:12 AM: file: /opt/build/repo/src/routes/home/home.component.jsx
> 12:37:12 AM: error during build:
> 12:37:12 AM: RollupError: Could not resolve ../../components/front-splash/front-splash.component from src/routes/home/home.component.jsx
> 12:37:12 AM:     at error (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:2124:30)
> 12:37:12 AM:     at ModuleLoader.handleInvalidResolvedId (file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:23990:24)
> 12:37:12 AM:     at file:///opt/build/repo/node_modules/rollup/dist/es/shared/node-entry.js:23952:26
> 12:37:12 AM: ​
> 12:37:12 AM: build.command failed                                        
> 12:37:12 AM: ────────────────────────────────────────────────────────────────
> 12:37:12 AM: ​
> 12:37:12 AM:   Error message
> 12:37:12 AM:   Command failed with exit code 1: vite build (https://ntl.fyi/exit-code-1)
> 12:37:12 AM: ​
> 12:37:12 AM:   Error location
> 12:37:12 AM:   In Build command from Netlify app:
> 12:37:12 AM:   vite build
> 12:37:12 AM: ​
> 12:37:12 AM:   Resolved config
> 12:37:12 AM:   build:
> 12:37:12 AM:     command: vite build
> 12:37:12 AM:     commandOrigin: ui
> 12:37:12 AM:     environment:
> 12:37:12 AM:       - VITE_REACT_APP_STRIPE_PUBLISHABE_KEY
> 12:37:12 AM:       - VITE_STRIPE_SECRET_KEY
> 12:37:12 AM:     publish: /opt/build/repo/dist
> 12:37:12 AM:     publishOrigin: ui
> 12:37:12 AM:   functionsDirectory: /opt/build/repo/netlify/functions
> 12:37:12 AM: Caching artifacts
> 12:37:12 AM: Started saving node modules
> 12:37:12 AM: Finished saving node modules
> 12:37:12 AM: Started saving build plugins
> 12:37:12 AM: Finished saving build plugins
> 12:37:12 AM: Started saving corepack cache
> 12:37:12 AM: Finished saving corepack cache
> 12:37:12 AM: Started saving pip cache
> 12:37:12 AM: Finished saving pip cache
> 12:37:12 AM: Started saving emacs cask dependencies
> 12:37:12 AM: Finished saving emacs cask dependencies
> 12:37:12 AM: Started saving maven dependencies
> 12:37:12 AM: Finished saving maven dependencies
> 12:37:12 AM: Started saving boot dependencies
> 12:37:12 AM: Finished saving boot dependencies
> 12:37:12 AM: Started saving rust rustup cache
> 12:37:12 AM: Finished saving rust rustup cache
> 12:37:12 AM: Started saving go dependencies
> 12:37:12 AM: Finished saving go dependencies
> 12:37:13 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
> 12:37:13 AM: Failing build: Failed to build site
> 12:37:13 AM: Finished processing build request in 17.404s

Thank you in advance for anyone who takes the time to point me in the right direction :heart:

@DevonGifford This is likely caused by case sensitivity.

The key part of the error is:

12:37:12 AM: RollupError: Could not resolve ../../components/front-splash/front-splash.component from src/routes/home/home.component.jsx

If you open the src/routes/home/home.component.jsx file you see:

So you’re telling it to load:

../../components/footer/footer.component

Except there is no components folder, your folder is Components:

Make sure to be consistent with your use of uppercase/lowercase or use only lowercase for your own sanity.

1 Like

Thank you for your time Nathan, I truly appreciate you! :pray:

You are correct this was the issue.

I thought I had solved this however when I changed the capitalization of some of the directories names, git didn’t seem to pick up on the directory/folder name changes - more quirks I am learning about in case preserving and case insensitivity.

Thank you for catching that one for me!

For anyone else who comes across this
I found the following git command helpful in solving this issue:

git config core.ignorecase false

However, there are a few caveats with this command:

  • This can cause some issues and strange behaviours and therefore is not encouraged by the git-config manual. However as a temporary solution to the above issue, it works fine, just revert back to true.

  • Secondly, beware this will give duplicated files/folders when pushing files/folders with same name but different capitalization in case insensitive OS - like Windows

I solved this issue by simply deleting the old directories in github and then just updated my local repository using:

git fetch origin master
git reset --hard FETCH_HEAD

Thank you once again @nathanmartin

Hi @DevonGifford i’m glad you found a solution! This is awesome and thanks for sharing your detailed solution with the community. (:

1 Like