Module not found: Error: Can't resolve './components/Layout/Layout' in '/opt/build/repo/src' (funny-lily-f3384c)

site name: funny-lily-f3384c
custom domain: none

issue:

The local assembly passes without problems. During the development of the project, most of the names of the components were renamed (component → Component), perhaps the reason lies in this.

In the application, I added the structure of the react project and package.json

Platform: Windows 10

[Build settings:
Runtime
Not set
Base directory
Not set
Build command
npm run build
Publish directory
build
Deploy log visibility
Logs are public
Build status
Active

Local versions:
$ npm -v
8.15.0
$ node -v
v16.17.0

Build Log:
8:47:40 PM: build-image version: a968751fa4fa5480005f9e300e07554d2cf87d06 (focal)
8:47:40 PM: buildbot version: 8b65fed9bc22a54aead1b50de89fea883757023a
8:47:40 PM: Fetching cached dependencies
8:47:40 PM: Failed to fetch cache, continuing with build
8:47:40 PM: Starting to prepare the repo for build
8:47:40 PM: No cached dependencies found. Cloning fresh repo
8:47:40 PM: git clone --filter=blob:none GitHub - denyshutsal/van-life
8:47:40 PM: Preparing Git Reference refs/heads/main
8:47:41 PM: Parsing package.json dependencies
8:47:42 PM: Starting to install dependencies
8:47:42 PM: Python version set to 3.8
8:47:42 PM: Attempting Ruby version 2.7.2, read from environment
8:47:43 PM: Using Ruby version 2.7.2
8:47:43 PM: Started restoring cached go cache
8:47:43 PM: Finished restoring cached go cache
8:47:43 PM: Installing Go version 1.19.5 (requested 1.19.5)
8:47:48 PM: go version go1.19.5 linux/amd64
8:47:48 PM: Using PHP version 8.0
8:47:49 PM: v16.20.0 is already installed.
8:47:50 PM: Now using node v16.20.0 (npm v8.19.4)
8:47:50 PM: Enabling Node.js Corepack
8:47:50 PM: Started restoring cached build plugins
8:47:50 PM: Finished restoring cached build plugins
8:47:50 PM: Started restoring cached corepack dependencies
8:47:50 PM: Finished restoring cached corepack dependencies
8:47:50 PM: No npm workspaces detected
8:47:50 PM: Started restoring cached node modules
8:47:50 PM: Finished restoring cached node modules
8:47:50 PM: Installing npm packages using npm version 8.19.4
8:47:55 PM: npm WARN deprecated w3c-hr-time#1.0.2: Use your platform’s native performance.now() and performance.timeOrigin.npm WARN deprecated stable#0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: Array.prototype.sort() - JavaScript | MDN
8:47:55 PM: npm WARN deprecated sourcemap-codec#1.4.8: Please use #jridgewell/sourcemap-codec instead
8:47:55 PM: npm WARN deprecated rollup-plugin-terser#7.0.2: This package has been deprecated and is no longer maintained. Please use #rollup/plugin-terser
8:47:57 PM: npm WARN deprecated svgo#1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
8:48:02 PM: added 1517 packages, and audited 1518 packages in 12s
8:48:02 PM: 231 packages are looking for funding
8:48:02 PM: run npm fund for details
8:48:02 PM: 9 vulnerabilities (1 moderate, 8 high)
8:48:02 PM: To address issues that do not require attention, run:
8:48:02 PM: npm audit fix
8:48:02 PM: To address all issues (including breaking changes), run:
8:48:02 PM: npm audit fix --force
8:48:02 PM: Run npm audit for details.
8:48:02 PM: npm packages installed
8:48:03 PM: Install dependencies script success
8:48:03 PM: Starting build script
8:48:03 PM: Detected 1 framework(s)
8:48:03 PM: “create-react-app” at version “5.0.1”
8:48:03 PM: Section completed: initializing
8:48:05 PM: ​
8:48:05 PM: Netlify Build
8:48:05 PM: ────────────────────────────────────────────────────────────────
8:48:05 PM: ​
8:48:05 PM: ❯ Version
8:48:05 PM: #netlify/build 29.10.1
8:48:05 PM: ​
8:48:05 PM: ❯ Flags
8:48:05 PM: baseRelDir: true
8:48:05 PM: buildId: 644eb7c3215501091f6b7f2a
8:48:05 PM: deployId: 644eb7c3215501091f6b7f2c
8:48:05 PM: ​
8:48:05 PM: ❯ Current directory
8:48:05 PM: /opt/build/repo
8:48:05 PM: ​
8:48:05 PM: ❯ Config file
8:48:05 PM: No config file was defined: using default values.
8:48:05 PM: ​
8:48:05 PM: ❯ Context
8:48:05 PM: production
8:48:05 PM: ​
8:48:05 PM: 1. Build command from Netlify app
8:48:05 PM: ────────────────────────────────────────────────────────────────
8:48:05 PM: ​
8:48:05 PM: $ npm run build
8:48:05 PM: > van-life#0.1.0 build
8:48:05 PM: > react-scripts build
8:48:06 PM: Creating an optimized production build…
8:48:07 PM: Failed to compile.
8:48:07 PM:
8:48:07 PM: Module not found: Error: Can’t resolve ‘./components/Layout/Layout’ in ‘/opt/build/repo/src’
8:48:07 PM: ​
8:48:07 PM: “build.command” failed
8:48:07 PM: ────────────────────────────────────────────────────────────────
8:48:07 PM: ​
8:48:07 PM: Error message
8:48:07 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
8:48:07 PM: ​
8:48:07 PM: Error location
8:48:07 PM: In Build command from Netlify app:
8:48:07 PM: npm run build
8:48:07 PM: ​
8:48:07 PM: Resolved config
8:48:07 PM: build:
8:48:07 PM: command: npm run build
8:48:07 PM: commandOrigin: ui
8:48:07 PM: publish: /opt/build/repo/build
8:48:07 PM: publishOrigin: ui
8:48:07 PM: Caching artifacts
8:48:07 PM: Started saving node modules
8:48:07 PM: Finished saving node modules
8:48:07 PM: Started saving build plugins
8:48:07 PM: Finished saving build plugins
8:48:07 PM: Started saving corepack cache
8:48:07 PM: Finished saving corepack cache
8:48:07 PM: Started saving pip cache
8:48:07 PM: Finished saving pip cache
8:48:07 PM: Started saving emacs cask dependencies
8:48:07 PM: Finished saving emacs cask dependencies
8:48:07 PM: Started saving maven dependencies
8:48:07 PM: Finished saving maven dependencies
8:48:07 PM: Started saving boot dependencies
8:48:07 PM: Finished saving boot dependencies
8:48:08 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
8:48:07 PM: Started saving rust rustup cache
8:48:07 PM: Finished saving rust rustup cache
8:48:07 PM: Started saving go dependencies
8:48:07 PM: Finished saving go dependencies
8:48:08 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:48:08 PM: Failing build: Failed to build site
8:48:08 PM: Finished processing build request in 28.91s

Hi @denyshutsal,

Thanks for reaching out and welcome to Netlify’s Support Forums!

I believe the issue may be caused as the folder for layout is all lowercase on your GitHub repo:

https://github.com/denyshutsal/van-life/blob/main/src/components/layout/Layout.js

Here it shows as layout/Layout and the error shows:

Module not found: Error: Can’t resolve ‘./components/Layout/Layout’ in ‘/opt/build/repo/src’

If you change the Folder name to Layout so it’s Layout/Layout.js and see if you continue to have the same issue.

We have a Support Guide here that may also help with troubleshooting:

Thank you, problem solved!

thanks for confirming!