Module.createRequireFromPath() is deprecated as of Node v13.1.0. An error is thrown when it is used.
No deprecation warnings from core when using latest stable version of Node.js.
This is logged to the console during the load plugins lifecycle:
ERROR
(node:9331) [DEP0130] DeprecationWarning: Module.createRequireFromPath() is deprecated. Use Module.createRequire() instead.
Line 6 of gatsby/src/utils/create-require-from-path.js is causing it.
A simple solution could be to just remove line 4 (polyfill comment) and line 6 and continue using the function as is.
If that's the route you'd like to take, let me know and I'd be happy to open a quick PR for it.
Thanks!
@hu0p Thanks for the report! I don't think we can remove the polyfill comment because we support back to Node 8.
It seems like we just need to add the new api and order them correctly.
Something like.
module.exports = Module.createRequire || Module.createRequireFromPath ||
function(filename) {...}
Would you be interested in contributing this fix and testing it?
Created this PR and can confirm it removes the deprecation warning 馃憤
Published in gatsby 2.18.2
I just encountered this same issue when spinning up my first Gatsby site. I ran npx gatsby new gatsby-site from the Quick Start video.
Did a quick Google for the issue, landed here, went to Releases page to see if 2.18.2 had landed, and it has. So, I'm thinking it must be lag in the publishing from my end, as I see 2.18.2 was published "6 hours ago" on GH Releases _and_ npmjs.org
Never mind, I forgot I had system version installed and had to update. 馃う鈥嶁檪
I needed to run: npm install gatsby@latest to fix this issue. I post this here for others who might stumble upon this.
Most helpful comment
I needed to run:
npm install gatsby@latestto fix this issue. I post this here for others who might stumble upon this.