Yarn build failed: unable to resolve component path

Good day y’all,

I’ve been trying to build my react website using Netlify and have faced this path resolving error.
I did this process locally and it worked like normal, however when brought to the Netlify platform, it fails.

Build log:

4:54:13 PM: Build ready to start
4:54:15 PM: build-image version: 122b31996ccaffd45d820a452d6227f8312110cc (focal)
4:54:15 PM: build-image tag: v4.5.3
4:54:15 PM: buildbot version: 7383bb8971c718de9618a700ec5049cb71af7102
4:54:15 PM: Building without cache
4:54:15 PM: Starting to prepare the repo for build
4:54:16 PM: No cached dependencies found. Cloning fresh repo
4:54:16 PM: git clone https://github.com/ohanagirl/songlist-bot
4:54:16 PM: Preparing Git Reference pull/12/head
4:54:17 PM: Parsing package.json dependencies
4:54:18 PM: Starting build script
4:54:18 PM: Installing dependencies
4:54:18 PM: Python version set to 2.7
4:54:18 PM: Downloading and installing node v16.14.0...
4:54:19 PM: Downloading https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz...
4:54:19 PM: Computing checksum with sha256sum
4:54:19 PM: Checksums matched!
4:54:22 PM: Now using node v16.14.0 (npm v8.3.1)
4:54:22 PM: Started restoring cached build plugins
4:54:22 PM: Finished restoring cached build plugins
4:54:23 PM: Attempting ruby version 2.7.2, read from environment
4:54:24 PM: Using ruby version 2.7.2
4:54:24 PM: Using PHP version 8.0
4:54:24 PM: Started restoring cached yarn cache
4:54:24 PM: Finished restoring cached yarn cache
4:54:25 PM: No yarn workspaces detected
4:54:25 PM: Started restoring cached node modules
4:54:25 PM: Finished restoring cached node modules
4:54:25 PM: Installing NPM modules using Yarn version 1.22.10
4:54:26 PM: yarn install v1.22.10
4:54:26 PM: [1/4] Resolving packages...
4:54:27 PM: [2/4] Fetching packages...
4:54:50 PM: [3/4] Linking dependencies...
4:54:50 PM: warning " > @chakra-ui/icons@1.1.5" has unmet peer dependency "@chakra-ui/system@>=1.0.0".
4:54:50 PM: warning "@chakra-ui/icons > @chakra-ui/icon@2.0.3" has unmet peer dependency "@chakra-ui/system@>=1.0.0".
4:54:50 PM: warning "@emotion/styled > @emotion/babel-plugin@11.7.2" has unmet peer dependency "@babel/core@^7.0.0".
4:54:50 PM: warning "@emotion/styled > @emotion/babel-plugin > @babel/plugin-syntax-jsx@7.16.5" has unmet peer dependency "@babel/core@^7.0.0-0".
4:54:59 PM: [4/4] Building fresh packages...
4:55:00 PM: Done in 33.49s.
4:55:00 PM: NPM modules installed using Yarn
4:55:00 PM: Started restoring cached go cache
4:55:00 PM: Finished restoring cached go cache
4:55:00 PM: go version go1.16.5 linux/amd64
4:55:00 PM: go version go1.16.5 linux/amd64
4:55:00 PM: Installing missing commands
4:55:00 PM: Verify run directory
4:55:02 PM: ​
4:55:02 PM: ────────────────────────────────────────────────────────────────
4:55:02 PM:   Netlify Build                                                 
4:55:02 PM: ────────────────────────────────────────────────────────────────
4:55:02 PM: ​
4:55:02 PM: ❯ Version
4:55:02 PM:   @netlify/build 26.3.0
4:55:02 PM: ​
4:55:02 PM: ❯ Flags
4:55:02 PM:   baseRelDir: true
4:55:02 PM:   buildId: 620767a52e8dcc8cec535616
4:55:02 PM:   deployId: 620767a52e8dcc8cec535618
4:55:02 PM: ​
4:55:02 PM: ❯ Current directory
4:55:02 PM:   /opt/build/repo
4:55:02 PM: ​
4:55:02 PM: ❯ Config file
4:55:02 PM:   /opt/build/repo/netlify.toml
4:55:02 PM: ​
4:55:02 PM: ❯ Context
4:55:02 PM:   deploy-preview
4:55:02 PM: ​
4:55:02 PM: ────────────────────────────────────────────────────────────────
4:55:02 PM:   1. Build command from Netlify app                             
4:55:02 PM: ────────────────────────────────────────────────────────────────
4:55:02 PM: ​
4:55:02 PM: $ yarn build
4:55:02 PM: yarn run v1.22.10
4:55:02 PM: $ parcel build index.html
4:55:03 PM: Building...
4:55:03 PM: 🚨 Build failed.
4:55:04 PM: @parcel/core: Failed to resolve '../components/SongList' from
4:55:04 PM: './src/pages/index.tsx'
4:55:04 PM:   /opt/build/repo/src/pages/index.tsx:3:22
4:55:04 PM:     2 | import React from 'react';
4:55:04 PM:   > 3 | import SongList from '../components/SongList';
4:55:04 PM:   >   |                      ^^^^^^^^^^^^^^^^^^^^^^^^
4:55:04 PM:     4 | import StatusBar from '../components/StatusBar';
4:55:04 PM:     5 | import UserGuide from '../components/UserGuide';
4:55:04 PM: @parcel/resolver-default: Cannot load file '../components/SongList' in
4:55:04 PM: './src/pages'.
4:55:04 PM: 💡 Did you mean '../components/Songlist'?
4:55:04 PM: 💡 Did you mean '../components/StatusBar'?
4:55:05 PM: error Command failed with exit code 1.
4:55:05 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
4:55:05 PM: ​
4:55:05 PM: ────────────────────────────────────────────────────────────────
4:55:05 PM:   "build.command" failed                                        
4:55:05 PM: ────────────────────────────────────────────────────────────────
4:55:05 PM: ​
4:55:05 PM:   Error message
4:55:05 PM:   Command failed with exit code 1: yarn build
4:55:05 PM: ​
4:55:05 PM:   Error location
4:55:05 PM:   In Build command from Netlify app:
4:55:05 PM:   yarn build
4:55:05 PM: ​
4:55:05 PM:   Resolved config
4:55:05 PM:   build:
4:55:05 PM:     command: yarn build
4:55:05 PM:     commandOrigin: ui
4:55:05 PM:     environment:
4:55:05 PM:       - ACCESS_TOKEN
4:55:05 PM:       - CLIENT_ID
4:55:05 PM:       - CLIENT_SECRET
4:55:05 PM:       - DISCORD_WEBHOOK
4:55:05 PM:       - REVIEW_ID
4:55:05 PM:       - TARGET_CHANNEL
4:55:05 PM:     publish: /opt/build/repo/dist
4:55:05 PM:     publishOrigin: ui
4:55:05 PM: Caching artifacts
4:55:05 PM: Started saving node modules
4:55:05 PM: Finished saving node modules
4:55:05 PM: Started saving build plugins
4:55:05 PM: Finished saving build plugins
4:55:05 PM: Started saving yarn cache
4:55:10 PM: Finished saving yarn cache
4:55:10 PM: Started saving pip cache
4:55:10 PM: Finished saving pip cache
4:55:10 PM: Started saving emacs cask dependencies
4:55:10 PM: Finished saving emacs cask dependencies
4:55:10 PM: Started saving maven dependencies
4:55:10 PM: Finished saving maven dependencies
4:55:10 PM: Started saving boot dependencies
4:55:10 PM: Finished saving boot dependencies
4:55:10 PM: Started saving rust rustup cache
4:55:10 PM: Finished saving rust rustup cache
4:55:10 PM: Started saving go dependencies
4:55:10 PM: Finished saving go dependencies
4:55:12 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:55:12 PM: Creating deploy upload records
4:55:12 PM: Failing build: Failed to build site
4:55:12 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
4:55:12 PM: Finished processing build request in 57.39493283s

Thank y’all for spending the time!

Hey @JustinYeoh93,

Is this related:

2 Likes

This is the solution!
To anyone who has never dealth with directory sensitivity, git does not take that into account.
So our folder was changed from Songlist to SongList.
Git did not catch this and update the history as required.
So, the build failed when its checked out by netlify’s builder.

1 Like

Glad everything is working for you now, @JustinYeoh93 :clap: