adobe / aem-sample-we-retail-journal

We.Retail Journal is a sample showcasing SPA Editing capabilities in AEM using React and Angular
Apache License 2.0
70 stars 69 forks source link

Getting window is not defined on my own project #79

Closed GonzaloCalandria closed 4 years ago

GonzaloCalandria commented 4 years ago

Hello everyone! I'm trying to apply this to my own project and I'm having the following error when I try to run my node server

C:\Projects\amc-demo\development\react-app\node_modules\u2f-api-polyfill\u2f-api-polyfill.js:14
  if ('u2f' in window || !('chrome' in window)) {
               ^

ReferenceError: window is not defined
    at C:\Projects\amc-demo\development\react-app\node_modules\u2f-api-polyfill\u2f-api-polyfill.js:14:16
    at Object.<anonymous> (C:\Projects\amc-demo\development\react-app\node_modules\u2f-api-polyfill\u2f-api-polyfill.js:753:3)
    at Module._compile (internal/modules/cjs/loader.js:868:30)
    at Module._compile (C:\Projects\amc-demo\development\react-app\node_modules\pirates\lib\index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:879:10)
    at Object.newLoader [as .js] (C:\Projects\amc-demo\development\react-app\node_modules\pirates\lib\index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:731:32)
    at Function.Module._load (internal/modules/cjs/loader.js:644:12)
    at Module.require (internal/modules/cjs/loader.js:771:19)
    at require (internal/modules/cjs/helpers.js:68:18)

I read that I can't use window object with server side rendering but I can't find anything on the net to fix this.. so I hope you can help me.

pfauchere commented 4 years ago

Indeed window doesn't exist on a Node server. I remember that we used a library to manage that scenario. You may have to do the same

GonzaloCalandria commented 4 years ago

Thank you @pfauchere for your answer! and do you have some sample for that scenario that you mention?