When working from a js template, it’s helpful to make a deep copy, so the original template is preserved. I have run into some issues with this many times, and it still bites me.
Debugging
Trace deprecation
Replace node_modules/gatsby/dist/bin/gatsby with the runner of the script.
This helped me find an issue I was running into with Gatsby 4.0 on build. The error I was seeing was:
This case was caused by gatsby-plugin-bundle-stats and was fixed when commented out.
Logging to Terminal
When using a standard console log, console.log('stars', stars), to the terminal in a node.js app, you might see some of the values at a certain depth be represented by [object] or [Array]. Let’s consider the following data:
With console.log("nachos", nachos);, we get:
To see the rest of the values we can use console.dir() with the first argument being the object to log and the second specifying the depth. In this case, we’ll set the depth to null to show all levels.
So console.dir({ nachos }, { depth: null }); gives us: