Perfect Scroll bar error no element is specified to initialize PerfectScrollbar on windows

Johnny Martin picture Johnny Martin · Jun 6, 2019 · Viewed 7.3k times · Source

I am getting this error on server start on react js.

Error: no element is specified to initialize PerfectScrollbar

However it is working fine on friend MAC OS. I am using windows.

I am using this version: "perfect-scrollbar": "^1.4.0",

Answer

groovyDynamics picture groovyDynamics · Apr 15, 2020

Quite old question but I'll post my solution since I had the same problem. I was having the same error message:

Error: no element is specified to initialize PerfectScrollbar

In my case, it seems that I was calling PerfectScrollbar on an element that didn't exist. I had:

const asideBody = new PerfectScrollbar('.aside-body', {
    suppressScrollX: true
});

And I was having the error in the pages I didn't have any element in the DOM with class="aside-body".

So I managed to only call PerfectScrollbar in the appropriate pages.