echarts-liquidfill icon indicating copy to clipboard operation
echarts-liquidfill copied to clipboard

nextjs 下报 ReferenceError: self is not defined

Open nshen opened this issue 4 years ago • 3 comments

ReferenceError: self is not defined
    at Object.<anonymous> (/home/nn/github/nextV/node_modules/echarts-liquidfill/dist/echarts-liquidfill.js:10:4)
"echarts": "5.1.0",
"echarts-for-react": "^3.0.1",
"echarts-gl": "^2.0.8",
"echarts-liquidfill": "3.1.0",

nshen avatar Oct 27 '21 06:10 nshen

The same thing is happening to me, but with other libs! I do not yet know how to fix that error.

mysticaltech avatar Dec 01 '21 15:12 mysticaltech

hi @mysticaltech this is due to ssr ssg relative things, I solved by dynamic import it

// fix ssr error
if (isClient()) {
  // @ts-ignore
  import('echarts-liquidfill');
}
/**
 * nextjs-utils
 */
export function isClient(): boolean {
  return typeof window !== 'undefined';
}

nshen avatar Dec 02 '21 01:12 nshen

Thanks for the info, my problem is that I do not even know where the issue comes from as tracing is not showing anywhere! Also not using this very library the issue belongs to.

ksnip_20211201-164101

mysticaltech avatar Dec 02 '21 15:12 mysticaltech