1

While making a portfolio website with Next.js, this is some sort of scrolling error that I'm getting from .next folder in my project folder.

Whenever I'm trying to get the mobile responsive view of the website this is the error I'm facing

Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'scrollTo')

This is the location of the error file

.next\static\chunks\pages\index.js (14:16) @ scroll

This is the code in that location

function _arrayLikeToArray(arr, len) {
  if (len == null || len > arr.length) len = arr.length;

  for (var i = 0, arr2 = new Array(len); i < len; i++) {
    arr2[i] = arr[i];
  }

  return arr2;
}

This is the snapshot of the error

enter image description here

I can run the website locally even when the error is showing. Is it gonna be a buggy thing if I deploy it?

How do I fix this?

4
  • 1
    Runtime is on browser, use window.scrollTo instead. Commented Sep 9, 2021 at 6:53
  • 1
    It has worked. Thank you. Commented Sep 9, 2021 at 11:45
  • Every time I reopen the app locally, it comes back with the same error. Again it's an error from the .next folder, same location, same code block. Commented Sep 9, 2021 at 13:30
  • Hey, I put an answer down below to explain that too. Commented Sep 9, 2021 at 13:46

1 Answer 1

3

You've got this error on Runtime and it is on browser

Since node is not available on the browser (only on node), you will need to use window.scrollTo instead

To completely remove it from the error logs, do a rebuilt so your .next will be wipe out and take the latest changes.

Sign up to request clarification or add additional context in comments.

2 Comments

Is it possible to update my next from the integrated terminal?
Sorry for the late reply. Just “npm run build” will clear the old .next folder content

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.