Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
360 views
in Technique[技术] by (71.8m points)

wordpress - Unable to resolve

Not sure what is wrong but I am getting this error :

Generating development SSR bundle failed

Can't resolve '../../public/page-data/sq/d/3873950781.json' in '/Users/Zack/Desktop/wp-gatsby/beautiful-gatsby-site/src/components'

If you're trying to use a package make sure that '../../public/page-data/sq/d/3873950781.json' is installed. If you're trying to use a local file make sure that the path is correct.

File: src/components/SiteInfo.js

not finished Building development bundle - 2.257s .

I can't understand why as I think my syntax is fine

src/components/SiteInfo.js:

import React from 'react';
import {graphql, StaticQuery} from 'gatsby';
import styled from 'styled-components';

const SiteInfoWrapper = styled.div`
    flex-grow: 1;
`

const SiteInfo = () => (
   <StaticQuery
   
    query={graphql`
        query b {
            allWordpressSiteMetadata {
                nodes {
                    name
                    description
                }
            }
        }
    `}

    render={ props => (
        <SiteInfoWrapper>
            <div>

                {props.allWordpressSiteMetadata.nodes.name}

                {props.allWordpressSiteMetadata.nodes.description}

            </div>

        </SiteInfoWrapper>
    )

    }

   />
)

export default SiteInfo;

Is anyone able to help with why I am getting this error?

Thank you so much

question from:https://stackoverflow.com/questions/65886033/unable-to-resolve

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Generally a path like:

src/components/SiteInfo.js:

Is not well constructed since it's not relative to anything. You may need to add some kind of relativity from the file where you are importing SiteInfo component, like:

import SiteInfo from "../../src/components/SiteInfo" // or "./src/components/SiteInfo"

const OtherComponent =(props)=>{
return <div> some stuff </div>

}

Check the path using relativity from the current file (../../src/components/SiteInfo) or from the root of the project (./src/components/SiteInfo).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...