shepherd-pro/react-shepherd

Getting window is not defined error.

Closed this issue · 3 comments

I am trying to use react-shepherd in a project. When I try to build it locally, I get this error, saying window is not defined. I am using react 16.3

/home/kash296/myProject/node_modules/react-shepherd/dist/Shepherd.js:4342
[1] var w = window;
[1] ^
[1]
[1] ReferenceError: window is not defined
[1] at Object.polyfill (/home/kash296/myProject/node_modules/react-shepherd/node_modules/shepherd.js/dist/js/shepherd.esm.js:4333:15)
[1] at Object. (/home/kash296/myProject/node_modules/react-shepherd/node_modules/shepherd.js/dist/js/shepherd.esm.js:4671:14)
[1] at Module._compile (internal/modules/cjs/loader.js:999:30)
[1] at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
[1] at Object.require.extensions. [as .js] (/home/kash296/myProject/node_modules/babel-register/lib/node.js:152:7)
[1] at Module.load (internal/modules/cjs/loader.js:863:32)
[1] at Module._load (internal/modules/cjs/loader.js:708:14)
[1] at Function.module._load (/home/kash296/myProject/node_modules/piping/lib/piping.js:218:16)
[1] at Module.require (internal/modules/cjs/loader.js:887:19)
[1] at require (internal/modules/cjs/helpers.js:74:18)

@kash0296 sounds like you are using server side rendering, where there is no window.

@rwwagner90 actually yes. How can I get this to work with an app that uses server side rendering?

@kash0296 this thread has many options for you vercel/next.js#2473. You need to only run Shepherd client side.