Gatsby build error (webpack related maybe)

Viewed 2965

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?

8 Answers

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

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

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.

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

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

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

More about nvm here.

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

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

Related