medusa: Window is not defined (Storefront issue)
Hey there, I was trying to build a medusa app and I’m running into an issue on the storefront (generated from create-medusa-app):
eady - started server on 0.0.0.0:8000, url: http://localhost:8000
event - compiled client and server successfully in 663 ms (926 modules)
wait - compiling / (client and server)...
event - compiled client and server successfully in 399 ms (965 modules)
error - ReferenceError: window is not defined
at Object.<anonymous> (/home/robby/Dev/my-medusa-store/storefront/node_modules/@medusajs/medusa-js/dist/index.js:1:93559)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/home/robby/Dev/my-medusa-store/storefront/node_modules/medusa-react/dist/medusa-react.cjs.development.js:10:30)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10) {
page: '/'
}
wait - compiling /_error (client and server)...
event - compiled client and server successfully in 77 ms (966 modules)
ReferenceError: window is not defined
at Object.<anonymous> (/home/robby/Dev/my-medusa-store/storefront/node_modules/@medusajs/medusa-js/dist/index.js:1:93559)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/home/robby/Dev/my-medusa-store/storefront/node_modules/medusa-react/dist/medusa-react.cjs.development.js:10:30)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
I generated the site with create-medusa-app (on node 16):
npx create-medusa-app
medusa-starter-default
Next.js Starter
Same issue with the gatsby-starter and medusa.express (next.js).
Any idea?
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 6
- Comments: 21 (5 by maintainers)
Thanks for reporting it everybody, and sorry for the inconvenience. The issue has been fixed and merged and should be released on Wednesday at the latest as
@medusajs/medusa-js@1.3.7
andmedusa-react@4.0.2
.If this is blocking you right here and now, you can downgrade your version to
@medusajs/medusa-js@1.3.5
andmedusa-react@4.0.0
, or use the snapshot version of the fixed packages that is available as@medusajs/medusa-js@1.3.7-snapshot-20230116155119
andmedusa-react@4.0.2-snapshot-20230116155119
.When updating/downgrading your dependencies you may need to clear node modules and do a fresh
yarn/npm install
😄Will keep the issue open for visibility.
Forcing version of
@medusajs/medusa-js
, solved the problem:Thank you for raising this! We are aware of the issue, and are testing a hotfix that should be out shortly.
Same problem here.
I found a temporary workaround until the bug is fixed running this commands in the storefront directory:
Source https://github.com/medusajs/medusa/pull/3016#issuecomment-1380918911
The front was not usable at all The fix seems working for me #3016 (check my comment but I’m not sure about the snapshot to use)
@robbyklein Thanks for reporting this one. We’ll investigate your issue and get back asap!