"build.command" failed. Error refers to Webpack

Hey all,

I’ve been reading quite some topics searching for an answer to my problem but neither one helped so I’ll have to create a new topic. :slight_smile:

So my problem is as the title says, and here’s the log:

ERROR in ./src/pages/Home/Home.jsx 4:0-55
Module not found: Error: Can't resolve '../../components/Contact/Contact' in '/opt/build/repo/src/pages/Home'
 @ ./src/App.jsx 6:0-37 12:15-19
 @ ./src/index.jsx 4:0-24 6:104-107

webpack 5.2.0 compiled with 8 errors in 9584 ms
npm ERR! code ELIFECYCLE
10:10:39 PM: npm ERR! errno 1
10:10:39 PM: npm ERR! xxx@1.0.0 build:prod: `webpack --config webpack.prod.config.js`
10:10:39 PM: npm ERR! Exit status 1
10:10:39 PM: npm ERR!
10:10:39 PM: npm ERR! Failed at the xxx@1.0.0 build:prod script.
10:10:39 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:10:39 PM: npm ERR! A complete log of this run can be found in:
10:10:39 PM: npm ERR!     /opt/buildhome/.npm/_logs/2020-10-23T20_10_39_855Z-debug.log
10:10:39 PM: npm ERR! code ELIFECYCLE
10:10:39 PM: npm ERR! errno 1
10:10:39 PM: npm ERR! xxx@1.0.0 build: `npm run build:prod`
10:10:39 PM: npm ERR! Exit status 1
10:10:39 PM: npm ERR!
10:10:39 PM: npm ERR! Failed at the xxx@1.0.0 build script.
10:10:39 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:10:39 PM: npm ERR! A complete log of this run can be found in:
10:10:39 PM: npm ERR!     /opt/buildhome/.npm/_logs/2020-10-23T20_10_39_885Z-debug.log
10:10:39 PM: ​
10:10:39 PM: ┌─────────────────────────────┐
10:10:39 PM: │   "build.command" failed    │
10:10:39 PM: └─────────────────────────────┘
10:10:39 PM: ​
10:10:39 PM:   Error message
10:10:39 PM:   Command failed with exit code 1: CI= npm run build
10:10:39 PM: ​
10:10:39 PM:   Error location
10:10:39 PM:   In build.command from netlify.toml:
10:10:39 PM:   CI= npm run build
10:10:39 PM: ​
10:10:39 PM:   Resolved config
10:10:39 PM:   build:
10:10:39 PM:     command: CI= npm run build
10:10:39 PM:     commandOrigin: config

Hope someone can come up with a solution, thanks in advance and stay safe! :wink:

Do you have a repo we can see? :slight_smile:

That’s a lot of information mentioned there. There’s a missing file according to those lines. Kindly check the path or as @AaronP asked, share the repository.

@hrishikesh that’s just part of the “Can’t resolve” list, there’s more of the same actually. But the weird thing on my local machine I’m not getting any errors. Everything works fine.

I will see if I can make the repo public. FYI @AaronP

@hrishikesh @AaronP here it is:
https://github.com/andylemaire/DDVDriverTraining

Are you sure? I just downloaded your repo, deleted package-lock.json, ran npm install and then, npm run build, I get the following:

> ddvdrivertraining@1.0.0 build C:\Users\Hrishikesh\Desktop\DDVDriverTraining-master
> gulp; hugo --gc --minify

[16:29:29] Using gulpfile ~\Desktop\DDVDriverTraining-master\gulpfile.js
[16:29:29] Task never defined: ;
[16:29:29] To list available tasks, try running: gulp --tasks
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ddvdrivertraining@1.0.0 build: `gulp; hugo --gc --minify`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ddvdrivertraining@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Hrishikesh\AppData\Roaming\npm-cache\_logs\2020-10-24T10_59_29_976Z-debug.log

@hrishikesh I forgot to mention, you should use the branch react.

This will be merged in master as soon as everything works fine, and in that branch I also switched from npm to yarn (which also means there’s no package-lock.json).

Got it all fixed. Here’s the live website: https://zealous-almeida-580057.netlify.app/ and the repo:https://github.com/Hrishikesh-K/DDVDriverTraining-react. You can check its commit history. Took me around 4 to 5 tests to find out all the components as reported by Netlify log (the commit ‘Test 4’ https://github.com/Hrishikesh-K/DDVDriverTraining-react/commit/f5f87ff062a012ecb1aa7176f6c24f9e63ad11fa is the one that reall matters actually).

The problem was incorrect case for components. It works on Windows and macOS (that’s why it build successfully on my Windows laptop and you might be using either of the two), but, Netlify uses Ubuntu which is Linux based and Linux can’t work with the mixed cases. So, all your components are in the folders which start with a small case, while the pages start with a capital case. While importing the components, you need to maintain the case, but, instead, you were importing all the components with the starting letter capital.

2 Likes

Alright thanks a lot @hrishikesh!

I did read about that, and I double checked afterwards. But on my machine (macOS) the folders do have a capital letter (I created them like this). Does GitHub maybe change them to lowercase when they don’t have an extension or something like that?

Anyway, thanks again. :slight_smile:

I don’t think so, because the folders in your page folder are still all capital. But, if you want to try, this page: [v2] Build breaking on Netlify · Issue #8205 · gatsbyjs/gatsby · GitHub suggests you can do something like git config core.ignorecase false. I’m not sure how and where to use it though.

Alright, I just renamed them to uppercase again.

Will try out the ignorecase suggestion.