Can't resolve 'react-icons/hi' in '/opt/build/repo/gatsby/src/components'

UPDATE: Removed react-icons and moved to Font-Awesome for React. SOLVED

I’m trying to build at patrickfranzport.netlify.app and it keeps failing.
My repo consists of two directories, one for gatsby and one for sanity. I’m only having it build the gatsby directory. This builds and serves fine on my local.

Thanks for the help!

Here is my deploy log:

10:25:05 AM: ────────────────────────────────────────────────────────────────

10:25:05 AM: Netlify Build
10:25:05 AM: ────────────────────────────────────────────────────────────────
10:25:05 AM: ​
10:25:05 AM: ❯ Version
10:25:05 AM: @netlify/build 10.2.2
10:25:05 AM: ​
10:25:05 AM: ❯ Flags
10:25:05 AM: deployId: 606b479c44889c000787a71c
10:25:05 AM: ​
10:25:05 AM: ❯ Current directory
10:25:05 AM: /opt/build/repo/gatsby
10:25:05 AM: ​
10:25:05 AM: ❯ Config file
10:25:05 AM: No config file was defined: using default values.
10:25:05 AM: ​
10:25:05 AM: ❯ Context
10:25:05 AM: production
10:25:06 AM: ​
10:25:06 AM: ────────────────────────────────────────────────────────────────
10:25:06 AM: 1. Build command from Netlify app
10:25:06 AM: ────────────────────────────────────────────────────────────────
10:25:06 AM: ​
10:25:06 AM: $ gatsby build
10:25:09 AM: success open and validate gatsby-configs - 0.042s
10:25:10 AM: success load plugins - 0.965s
10:25:10 AM: success onPreInit - 0.096s
10:25:10 AM: success initialize cache - 0.007s
10:25:10 AM: success copy gatsby files - 0.076s
10:25:10 AM: info [sanity] Fetching remote GraphQL schema
10:25:10 AM: info [sanity] Transforming to Gatsby-compatible GraphQL SDL
10:25:10 AM: info [sanity] Stitching GraphQL schemas from SDL
10:25:10 AM: success onPreBootstrap - 0.239s
10:25:10 AM: success createSchemaCustomization - 0.014s
10:25:10 AM: info [sanity] Fetching export stream for dataset
10:25:11 AM: info [sanity] Done! Exported 30 documents.
10:25:11 AM: success Checking for changed pages - 0.000s
10:25:11 AM: success source and transform nodes - 0.548s
10:25:11 AM: success building schema - 0.680s
10:25:11 AM: info Total nodes: 81, SitePage nodes: 4 (use --verbose for breakdown)
10:25:11 AM: success createPages - 0.057s
10:25:11 AM: success Checking for changed pages - 0.000s
10:25:12 AM: success createPagesStatefully - 0.059s
10:25:12 AM: success update schema - 0.084s
10:25:12 AM: success onPreExtractQueries - 0.005s
10:25:14 AM: success extract queries from components - 2.472s
10:25:14 AM: success write out redirect data - 0.001s
10:25:14 AM: success Build manifest and related icons - 0.174s
10:25:14 AM: success onPostBootstrap - 0.177s
10:25:14 AM: info bootstrap finished - 8.751s
10:25:15 AM: success run static queries - 0.391s - 5/5 12.80/s
10:25:17 AM: success run page queries - 2.390s - 6/6 2.51/s
10:25:17 AM: success write out requires - 0.087s
10:25:41 AM: failed Building production JavaScript and CSS bundles - 23.781s
10:25:41 AM: error Generating JavaScript bundles failed
10:25:41 AM: Can’t resolve ‘react-is’ in ‘/opt/build/repo/gatsby/node_modules/styled-components/dist’
10:25:41 AM: If you’re trying to use a package make sure that ‘react-is’ is installed. If you’re trying to use a local file make sure that the path is correct.
10:25:41 AM: error Generating JavaScript bundles failed
10:25:41 AM: Can’t resolve ‘react-icons/hi’ in ‘/opt/build/repo/gatsby/src/components’
10:25:41 AM: If you’re trying to use a package make sure that ‘react-icons/hi’ is installed. If you’re trying to use a local file make sure that the path is correct.
10:25:41 AM: error Generating JavaScript bundles failed
10:25:41 AM: Can’t resolve ‘react-icons/ai’ in ‘/opt/build/repo/gatsby/src/components’
10:25:41 AM: If you’re trying to use a package make sure that ‘react-icons/ai’ is installed. If you’re trying to use a local file make sure that the path is correct.
10:25:41 AM: error Generating JavaScript bundles failed
10:25:41 AM: Can’t resolve ‘react-icons/gi’ in ‘/opt/build/repo/gatsby/src/components’
10:25:41 AM: If you’re trying to use a package make sure that ‘react-icons/gi’ is installed. If you’re trying to use a local file make sure that the path is correct.
10:25:41 AM: error Generating JavaScript bundles failed
10:25:41 AM: Can’t resolve ‘react-icons/gr’ in ‘/opt/build/repo/gatsby/src/components’
10:25:41 AM: If you’re trying to use a package make sure that ‘react-icons/gr’ is installed. If you’re trying to use a local file make sure that the path is correct.
10:25:41 AM: ​
10:25:41 AM: ────────────────────────────────────────────────────────────────
10:25:41 AM: “build.command” failed
10:25:41 AM: ────────────────────────────────────────────────────────────────
10:25:41 AM: ​
10:25:41 AM: Error message
10:25:41 AM: Command failed with exit code 1: gatsby build
10:25:41 AM: ​
10:25:41 AM: Error location
10:25:41 AM: In Build command from Netlify app:
10:25:41 AM: gatsby build
10:25:41 AM: ​
10:25:41 AM: Resolved config
10:25:41 AM: build:
10:25:41 AM: base: /opt/build/repo/gatsby
10:25:41 AM: command: gatsby build
10:25:41 AM: commandOrigin: ui
10:25:41 AM: publish: /opt/build/repo/gatsby/public
10:25:41 AM: Caching artifacts
10:25:41 AM: Started saving node modules
10:25:41 AM: Finished saving node modules
10:25:41 AM: Started saving build plugins
10:25:41 AM: Finished saving build plugins
10:25:41 AM: Started saving pip cache
10:25:42 AM: Finished saving pip cache
10:25:42 AM: Started saving emacs cask dependencies
10:25:42 AM: Finished saving emacs cask dependencies
10:25:42 AM: Started saving maven dependencies
10:25:42 AM: Finished saving maven dependencies
10:25:42 AM: Started saving boot dependencies
10:25:42 AM: Finished saving boot dependencies
10:25:42 AM: Started saving rust rustup cache
10:25:42 AM: Finished saving rust rustup cache
10:25:42 AM: Started saving go dependencies
10:25:42 AM: Finished saving go dependencies
10:25:44 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:25:44 AM: Failing build: Failed to build site
10:25:44 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
10:25:44 AM: Finished processing build request in 2m1.485804518s

Looks like you’re missing some dependencies (react-is) in your package.json. Either that, or you have those dependencies, but inside the devDependencies section.

Maybe the path is incorrect or there’s come case problem in the name? If you can share your repo or a demo code, we can tell for sure.

Thanks for the response! Yea, I got rid of that error by manually installing react-is although it was a styled-components dependency. NPM must be taking the day off! Anyways that fixed styled-components, but no effect to react-icons.

I ended up scrapping react-icons and using font-awesome’s react icons. Worked great!

1 Like