Search code examples
reactjsgatsbynetlify

deploying gatsby (v2) to netlify errors


I'm having some issues deploying to netlify. These are the errors I receive:

Error: ./src/pages/index.js 12:55:30 PM: Module not found: Error: Can't resolve '../components/Featured' in '/opt/build /repo/src/pages' 12:55:30 PM: resolve '../components/Featured' in '/opt/build/repo/src/pages' 12:55:30 PM: using description file: /opt/build/repo/package.json (relative path: ./src/p ages) 12:55:30 PM: Field 'browser' doesn't contain a valid alias configuration

For some reason it can't find the components. Building locally works fine.

I used gatsby-starter w styled-components.

things I tried: I had some local building errors regarding the window undefined. I fixed these by conditionally including them as the manual proposes.

After applying this, I started receiving console logs from ‘workbox’.

(btw this is my first time trying to deploy to netlify) also the error Field 'browser' doesn't contain a valid alias configuration keeps repeating in the logs

here's a link to the full log I get from netlify


Solution

  • The errors are due to webpack not being able to resolve your relative paths. Make sure to use the correct case.

    import Hero from '../components/hero'
    import Introduce from '../components/introduce'
    import HelpMeHelpYou from '../components/helpmehelpyou'
    import Featured from '../components/featured'
    import Testimonials from '../components/testimonials'
    import Projects from '../components/projects'
    import Gallery from '../components/gallery'
    import Outroduce from '../components/outroduce'
    

    enter image description here