I was having trouble with
netlify dev playing nicely with gatsby, and in the process of writing this thread it (seems to have?) started working. I thought I would post it anyway to share what I tried, how I was stuck, and how I got as far as I have, in case anyone else runs into the same problem, or if it can help netlify fix this problem.
I had an existing netlify site that I connected with the CLI and
netlify link, which all worked seamlessly. I am working on upgrading that site from a static html placeholder to a gatsby app. In the process I decided I wanted to use netlify functions, so as a step to being able to test them locally I decided to try out
netlify dev. This is why I installed the CLI and ran
netlify link - previously I only deployed with git hooks and didn’t worry about anything else.
For basic gatsby site development, running
npm run develop starts gatsby and everything works as expected.
If I ran
netlify dev then I saw that it triggered
npm run develop and at the end of the gatsby build, it would just sit there printing out a dot every second or two, and never get any farther.
I experimented with specifying a command
netlify dev -c "npm run build" -d public
This didn’t really work as expected either. Fortunately, the output gave me the hint that it was a simple static server because of the
-d flag. So I tried again, this time only using the -c flag:
❯ netlify dev -c “npm run build”
◈ Netlify Dev ◈
◈ Starting Netlify Dev with gatsby
Waiting for localhost:8000.
◈ Functions server is listening on 34567
> email@example.com build /Users/atcodes/DEV/…
> gatsby build
success open and validate gatsby-configs - 0.013s
success load plugins - 0.231s
success onPreInit - 0.001s
success delete html and css files from previous builds - 0.025s
success initialize cache - 0.004s
success copy gatsby files - 0.045s
success onPreBootstrap - 0.005s
success createSchemaCustomization - 0.002s
success source and transform nodes - 0.033s
success building schema - 0.200s
success createPages - 0.000s
success createPagesStatefully - 0.060s
success onPreExtractQueries - 0.000s
success update schema - 0.020s
success extract queries from components - 0.211s
success write out requires - 0.003s
success write out redirect data - 0.001s
success Build manifest and related icons - 0.097s
success onPostBootstrap - 0.098s
info bootstrap finished - 1.975 s
success run queries - 5.844s - 13/13 2.22/s
success Building static HTML for pages - 0.636s - 11/11 17.30/s
info Done building in 8.483945494 sec
◈ Error while killing child process: kill ESRCH
I was never able to get this to do anything but end in the error shown above.
Then I started writing this support request, and in the process tried a bare
netlify dev again to get a screen shot of the output, and, well… this time it worked! I don’t know what I could have done to fix it, but here we are.
Somewhere along the way I also added a netlify.toml file with only these contents:
[build] base = "./" publish = "public/" command = "npm run build" functions = "./.functions/"
I know that I saw
netlify dev fail after this file existed, but maybe this contributed to the success?