Home > Net >  Next build fails only on my machine with `Generating static pages (0/6)TypeError: n.replaceAll is no
Next build fails only on my machine with `Generating static pages (0/6)TypeError: n.replaceAll is no

Time:12-09

I am trying to build my Next.js project, but I am getting the error Generating static pages (0/6)TypeError: n.replaceAll is not a function at a file in my node_modules folder. Steps I have taken to try to identify where the problem is coming from:

(In the following when I say install&build I mean yarn install --frozen-lockfile, then next build

  1. delete node_modules and .next folder, insall&build -> fails
  2. clone the repo in a new folder and install&build -> fails
  3. Run this as a github action on github -> succeeds
  4. Run this as a github action on my machine using this library: https://github.com/nektos/act (that uses docker) -> succeeds
  5. do step 1 on my colleagues machine -> succeeds
  6. do step 2 on my colleagues machine -> succeds

The full error is:

Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: n.replaceAll is not a function
    at file:///home/sev/dev/frontend/node_modules/connectkit/build/index.es.js:682:37384
    at Array.forEach (<anonymous>)
    at rn (file:///home/sev/dev/frontend/node_modules/connectkit/build/index.es.js:682:37367)
    at file:///home/sev/dev/frontend/node_modules/connectkit/build/index.es.js:682:37304
    at Array.map (<anonymous>)
    at tn (file:///home/sev/dev/frontend/node_modules/connectkit/build/index.es.js:682:37270)
    at kn (file:///home/sev/dev/frontend/node_modules/connectkit/build/index.es.js:682:42706)
    at Wc (/home/sev/dev/frontend/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
    at Zc (/home/sev/dev/frontend/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
    at Z (/home/sev/dev/frontend/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)

CodePudding user response:

You get this error because String.prototype.replaceAll() is only supported from Node v15.0.0:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll#browser_compatibility

You will need to update your version of Node to at least this version.

I hope this helps to resolve your issue.

  • Related