Gatsby build error (webpack related maybe)
Asked Answered
M

9

12

I made a site with gatsby (npm init gatsby) and added some components and was working fine then:

I run npm run develop (after running it before fine) and get this:

failed Building development bundle - 13.532s
ERROR in ./.cache/app.js
Module build failed (from ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js):
Error: You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using
SourceMapConsumer

ERROR in ./.cache/polyfill-entry.js
Module build failed (from ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js):
Error: You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using
SourceMapConsumer

What causes this error and how can I fix this? I'm baffled. Tried with fresh new site and does the same thing.

I upgraded to latest version of node so maybe this has something to do with it. Can anyone help?

Mettlesome answered 24/4, 2022 at 19:0 Comment(0)
C
11

I can confirm that downgrading to node 16 fixes the issue.

Clactonian answered 29/4, 2022 at 8:30 Comment(0)
A
8

I was able to avoid downgrading to Node 16 by following instructions there: https://github.com/gatsbyjs/gatsby/issues/35607

I added this to my package.json:

  "resolutions": {
    "source-map": "^0.8.0-beta.0"
  },
  "dependencies": {
    "source-map": "^0.8.0-beta.0",
    ...

Then I did npm install.

After that, I could run npm run develop without any issues.

Atwood answered 3/6, 2022 at 14:53 Comment(2)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Sustain
+1 for the only one that's the actual answer and not "randomly stab in the dark with major version changes on our entire stack until it might work"!Broadcaster
D
2

Had the same issue on node version 18, when downgraded to node 16.15.0 it worked.

Dropper answered 5/5, 2022 at 3:16 Comment(0)
L
2

I have version Node v16.14.2 but still have the same problem, when I upgrade jest to the latest in my case from 27.4.5 to 28.1.1 it fix the problem. npm i -d jest@latest if you are using typescript don't forget to upgrade also @type npm i -d @types/jest@latest

Livvy answered 17/6, 2022 at 20:3 Comment(0)
Q
1

I had the same problem as you.I have downgraded node to the LTS version and it worked!

Quinnquinol answered 4/5, 2022 at 7:42 Comment(0)
B
1

had the same issue, downgraded node to 16 and its working fine now,

how to downgrade

$ npm install -g n $ n 6.10.3

how to check version

$ node -v

Blondy answered 4/5, 2022 at 15:0 Comment(1)
This works, just need to update the version: $ n 16.15.0Gusta
A
1

This worked:

  • Delete node_modules and package-lock.json
  • npm install
  • gatsby develop
Abana answered 6/2, 2023 at 13:21 Comment(1)
Solved same problem (with same error message) but NO gatsby dependency in project and yarn instead of npm. Doing: rm -rf node_modules yarn.lock && yarn.Heterozygote
P
0

I used nvm to downgrade from v18.1.0 to v16.5.0. The error is now gone.

More about nvm here.

Proterozoic answered 20/5, 2022 at 7:55 Comment(0)
F
-2

try do delete the .cache file and then run npm run develop

Faustino answered 24/4, 2022 at 19:7 Comment(9)
Tried this. And public folder. Nothing changed, unfortunately.Mettlesome
I actually also get another error after doing that: error:0308010C:digital envelope routines::unsupportedMettlesome
which node version you use!?Faustino
Updated to most recent so 18Mettlesome
Try to downgrade Node.JS to Latest Stable Version (16.14.2 LTS), it happened to me before and the solution is simply to always use the latest stable version not the current.Faustino
Just did that. Now i'm getting: TypeError: Cannot read properties of undefined (reading 'get')Mettlesome
that means there is a bug somewhere in your code, check in the terminal in which file this problem showFaustino
Yes it was. I guess the main issue was the node version, then something broke. Fixed now, thank you for your help :)Mettlesome
you're welcome, happy you fix it :)Faustino

© 2022 - 2024 — McMap. All rights reserved.