Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.1.30 - (ReferenceError: window is not defined) node_modules/@aws-amplify/ui/dist/aws-amplify-ui.js:1:289 #3615

Closed
anarerdene opened this issue Jul 9, 2019 · 11 comments
Assignees
Labels
bug Something isn't working UI Related to UI Components

Comments

@anarerdene
Copy link

1.1.30 - (ReferenceError: window is not defined) node_modules/@aws-amplify/ui/dist/aws-amplify-ui.js:1:289

@csatterlee
Copy link

I'm havingthe same issue with next.js, but having no issues with vanilla react. This is after using the solution here: #1535 to fix a similar error with the style.css file. The only amplify I'm using is withAuthenticator.

@tuliohc
Copy link

tuliohc commented Jul 10, 2019

Same here with version 1.1.28

@mkondel
Copy link

mkondel commented Jul 15, 2019

Possible quick fix is to add 'resolutions' to your package.json. Found in #3477.

  "resolutions": {
    "@aws-amplify/ui": "1.0.19"
  },

@BramDecuypere
Copy link

BramDecuypere commented Jul 18, 2019

Here is what I had to do to get it fixed asap in my project:

Step 1: remove all the current packages + package-lock.json (i'm using npm instead of yarn, for yarn, I guess the answer above works best)

rm -rf node_modules

Step 2: Add a command to the "preinstall" (if you already have something here use "&&") and resolutions of my package.json so it looks like this:
The preinstall is so this also happens on netlify your staging/production envs.
The resolutions is not taken into account for regular npm install's.

"scripts": {
  "preinstall": "npx npm-force-resolutions" 
}
"resolutions": {
  "@aws-amplify/ui": "1.0.19"
},

Step 2:: npm i again and start your project

Hope this helps!

@aldegoeij
Copy link

aldegoeij commented Jul 18, 2019

Same issue on Gatsby build, related tickets: #3486, #3506, #3615, #3015, #876, #3477 and webpack/webpack#6522

@aldegoeij
Copy link

Version 1.0.21-unstable.0 PR: #3512

@aldegoeij
Copy link

Possible quick fix is to add 'resolutions' to your package.json. Found in #3477.

  "resolutions": {
    "@aws-amplify/ui": "1.0.19"
  },

Actually 1.0.21-unstable.0 did the trick for me (with amplify/core on 1.1.30

@ajhool
Copy link

ajhool commented Jul 18, 2019

It appears that the fix for this has already been put together, a quick version push to just resolve this issue would be appreciated immensely

@csatterlee this issue is caused when React is rendered on the server (what next.js does with SSR) because "window" is available in the browser but is not available on the server. So, when next.js tries to render this code on the server, it cannot find the "window" object. When react executes on the browser, it can find the "window" object without issue. In general, this issue is resolved by checking whether "window" is defined before executing the code that depends on window.

@exoego
Copy link
Contributor

exoego commented Aug 23, 2019

Is this resolved by #3512 ?

@sammartinez
Copy link
Contributor

This issue is resolved. Closing issue as fix is completed.

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working UI Related to UI Components
Projects
None yet
Development

No branches or pull requests