Webpack fails in gatsby build for scoped packages

We have several packages that are scoped and some of them require other scoped packages. They are hosted in a private JFrog environment, and yarn is installing them successfully. The .npmrc and .yarnrc file are helping yarn find the right packages.
However after a gatsby build I am getting these errors:
11:24:29 AM: error #98123 WEBPACK
11:24:29 AM: Generating JavaScript bundles failed
11:24:29 AM: Can’t resolve ‘@printdeal/address-component’ in ‘/opt/build/repo/node_modules/@printdeal/authentication-component/dist/components/Register/Business’
11:24:29 AM: File: node_modules/@printdeal/authentication-component/dist/components/Register/Business/CustomBusinessForm.js
11:24:29 AM: See our docs page for more info on this error:
11:24:29 AM: error #98123 WEBPACK
11:24:29 AM: Generating JavaScript bundles failed
11:24:29 AM: Can’t resolve ‘@printdeal/address-component’ in ‘/opt/build/repo/node_modules/@printdeal/authentication-component/dist/components/Register/Private’
11:24:29 AM: File: node_modules/@printdeal/authentication-component/dist/components/Register/Private/PrivateRegisterForm.js
11:24:29 AM: See our docs page for more info on this error:
11:24:29 AM: error #98123 WEBPACK
11:24:29 AM: Generating JavaScript bundles failed
11:24:29 AM: Can’t resolve ‘@printdeal/address-component’ in ‘/opt/build/repo/src/components/checkout’
11:24:29 AM: File: src/components/checkout/CheckoutAddress.js
11:24:29 AM: See our docs page for more info on this error:
11:24:29 AM: error #98123 WEBPACK
11:24:29 AM: Generating JavaScript bundles failed
11:24:29 AM: Can’t resolve ‘@printdeal/chat-widget’ in ‘/opt/build/repo/src/components/widgets’
11:24:29 AM: File: src/components/widgets/ChatWidget.js
11:24:29 AM: See our docs page for more info on this error:
11:24:29 AM: error #98123 WEBPACK
11:24:29 AM: Generating JavaScript bundles failed
11:24:29 AM: Can’t resolve ‘@printdeal/data-layer-manager’ in ‘/opt/build/repo’
11:24:29 AM: File: gatsby-browser.js
11:24:29 AM: See our docs page for more info on this error:
11:24:29 AM: error #98123 WEBPACK
11:24:29 AM: Generating JavaScript bundles failed
11:24:29 AM: Can’t resolve ‘@printdeal/data-layer-manager’ in ‘/opt/build/repo/src/helpers/dataLayerHelpers’
11:24:29 AM: File: src/helpers/dataLayerHelpers/orderDataLayerHelper.js
11:24:29 AM: See our docs page for more info on this error: How to File an Issue | Gatsby
11:24:29 AM: error #98123 WEBPACK
11:24:29 AM: Generating JavaScript bundles failed
11:24:29 AM: Can’t resolve ‘@printdeal/data-layer-manager’ in ‘/opt/build/repo/src/helpers/dataLayerHelpers’
11:24:29 AM: File: src/helpers/dataLayerHelpers/authDataLayerHelper.js
11:24:29 AM: See our docs page for more info on this error:
11:24:29 AM: error #98123 WEBPACK
11:24:29 AM: Generating JavaScript bundles failed
11:24:29 AM: Can’t resolve ‘@printdeal/my-account’ in ‘/opt/build/repo/src/pages’
11:24:29 AM: File: src/pages/account.js
11:24:29 AM: See our docs page for more info on this error:
11:24:29 AM: error #98123 WEBPACK
11:24:29 AM: Generating JavaScript bundles failed
11:24:29 AM: Can’t resolve ‘@printdeal/validation’ in ‘/opt/build/repo/node_modules/@printdeal/authentication-component/dist/components/Register’
11:24:29 AM: File: node_modules/@printdeal/authentication-component/dist/components/Register/index.js

Google isn’t really providing me much help, scoped packages not being found by webpack · Issue #3939 · webpack/webpack · GitHub seems like it is related but I don’t understand what to do to fix this.
Also, when I run a build on my local machine, everything works without issues, so I’m assuming it is some kind of configuration setting. Can anyone help me out with this?

Hi @htesligte, do these packages happen to be installed as ‘devDependencies’? Perhaps the packages aren’t being installed during build because Gatsby sets NODE_ENV to production when using the ‘build’ command. What this does is it tells npm or yarn not to install those devDependencies, only dependencies. Hopefully you’re able to move those scoped packages to ‘dependencies’ and see if that helps.

I recently had the same problem. The issue was related to case-sensitivity, check that all your imports matches the file paths exactly. If I am not mistaken, for instance Mac’s filesystem is case-insensitive while Linux is case-sensitive.

1 Like

that is correct - case sensitivity is an issue on different systems and can cause unexpected behaviour. @htesligte - does this help at all?