Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gatsby serve doesn't work after running gatsby build #9964

Closed
Dogtiti opened this issue Nov 16, 2018 · 9 comments
Closed

gatsby serve doesn't work after running gatsby build #9964

Dogtiti opened this issue Nov 16, 2018 · 9 comments
Labels
status: awaiting author response Additional information has been requested from the author

Comments

@Dogtiti
Copy link

Dogtiti commented Nov 16, 2018

  • Node.js version:10.13.0
  • Gatsby version :2.4.5
  • Operation system : MacOS 10.14.1

gatsby build

success load plugins — 0.173 s
success onPreInit — 0.974 s
success delete html and css files from previous builds — 0.019 s
success initialize cache — 0.006 s
success copy gatsby files — 0.113 s
success onPreBootstrap — 0.011 s
⠂ source and transform nodesStarting to fetch data from Strapi (editors)
Starting to fetch data from Strapi (imgs)
Starting to fetch data from Strapi (articles)
⠄ source and transform nodesFetch Strapi data: 105.772ms
(node:33333) Warning: No such label 'Fetch Strapi data' for console.timeEnd()
(node:33333) Warning: No such label 'Fetch Strapi data' for console.timeEnd()
success source and transform nodes — 0.275 s
success building schema — 0.384 s

and then running gatsby serve
info gatsby serve running at: http://localhost:9000/

the page throw the error as follow image

image

however,the command gatsby develop work well

@jonniebigodes
Copy link

Can you provide extra information, namely a repository url, if the work you're doing is not private or protected? Also the result of gatsby info --clipboard, this so that we can look into the issue and try to help you better.

@Dogtiti
Copy link
Author

Dogtiti commented Nov 16, 2018

@jonniebigodes
thanks a lot !
here I create an repo https://github.com/Dogtiti/gatsby-test.git
And the result of gatsby info --clipboard

    OS: macOS 10.14.1
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
    Yarn: 1.12.1 - /usr/local/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 70.0.3538.102
    Safari: 12.0.1
  npmPackages:
    gatsby: ^2.0.19 => 2.0.48
    gatsby-image: ^2.0.15 => 2.0.20
    gatsby-plugin-manifest: ^2.0.5 => 2.0.9
    gatsby-plugin-offline: ^2.0.11 => 2.0.14
    gatsby-plugin-react-helmet: ^3.0.0 => 3.0.2
    gatsby-plugin-sharp: ^2.0.7 => 2.0.12
    gatsby-source-filesystem: ^2.0.4 => 2.0.8
    gatsby-source-strapi: ^0.0.5 => 0.0.5
    gatsby-transformer-sharp: ^2.1.4 => 2.1.8

maybe you have to comment some graphql to run it well

@kakadiadarpan
Copy link
Contributor

@Dogtiti can you provide the version of gatsby-cli that you are using?

@kakadiadarpan kakadiadarpan added the type: question or discussion Issue discussing or asking a question about Gatsby label Nov 16, 2018
@Dogtiti
Copy link
Author

Dogtiti commented Nov 16, 2018

@kakadiadarpan
v 2.4.5

@jonniebigodes
Copy link

jonniebigodes commented Nov 20, 2018

@Dogtiti sorry for the late response. But i had to do some digging to reproduce your issue.
I installed strapi and generated a new dummy cms to test your code.
Filled it with some dummy content and tried issuing gatsby build and it kept throwing errors, namely

TypeError: Cannot read property 'data' of undefined

So i went on and did some more digging and for what i've seen of your code you used this as a source for your code right?
After comparing both of them i saw that you had some errors in your code.
On your gatsby-node.js file you had:

const makeRequest = (graphql, request) => new Promise((resolve, reject) => {
    
    resolve(
        graphql(request).then(result => {
           
            if (result.errors) {
               reject.errors
            }
        })
    )
    return result;
})

With that piece of code you had the build will always fail.
With the following change on your code you can build it successfully and issue gatsby serve to see your app running:

const makeRequest = (graphql, request) => new Promise((resolve, reject) => {
    
    resolve(
        graphql(request).then(result => {
            
            if (result.errors) {
               reject(reject.errors)
            }
            return result
        })
    )
})

And also was getting some issues with gatsby-plugin-offline, so for the sake of the issue i disabled and all went ok. I got your code to build and run with gatsby serve

@jonniebigodes jonniebigodes added status: awaiting author response Additional information has been requested from the author and removed type: question or discussion Issue discussing or asking a question about Gatsby labels Dec 14, 2018
@jonniebigodes
Copy link

@Dogtiti did you manage to solve your issue? if so close this one or let me know so i can close it sounds good?

@Dogtiti
Copy link
Author

Dogtiti commented Dec 16, 2018

@jonniebigodes I am sorry that I have not responded for so long,yeah,you can close it ,I have soved it

@jonniebigodes
Copy link

Glad you resolved your issue. I'm closing this as of now. Thanks for using Gatsby 👍

@sasivarnakumar
Copy link

I was following the gatsby tutorial part 9. I also had the same issue @Dogtiti reported.

Like jonniebigodes advised, I reviewed the gatsby-node.js file

In my case, I had a console.log() statement. I removed the console log statement and tried to build and serve. Was successful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: awaiting author response Additional information has been requested from the author
Projects
None yet
Development

No branches or pull requests

4 participants