amplify-js: "WINDOW NOT DEFINED"... again :-(

Describe the bug Importing the latest aws-amplify into a nuxt application crashes with a “Window not defined” error

To Reproduce In a Nuxt Js application (and probably any SSR framework), try to import the latest aws-amplify

Expected behavior Should not crash

Additional context Most certainly a regression for #3477

My latest working config is with aws-amplify version 1.1.36 with the following resolutions in package.json:

  "resolutions": {
    "@aws-amplify/analytics": "1.2.23",
    "@aws-amplify/api": "1.0.42",
    "@aws-amplify/auth": "1.2.31",
    "@aws-amplify/cache": "1.0.32",
    "@aws-amplify/core": "1.1.0",
    "@aws-amplify/interactions": "1.0.35",
    "@aws-amplify/predictions": "1.0.3",
    "@aws-amplify/pubsub": "1.1.0",
    "@aws-amplify/storage": "1.1.0"
 }

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 29 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Confirmed working using @aws-amplify/api@^1.2.4-unstable.3 and @aws-amplify/auth@^1.4.4-unstable.3.

@Amplifiyer shouldn’t this issue be reopened ?

Still getting this issue.

@Amplifiyer , i installed new versions of Amplify and Amplify React. Window Not Defined Error is gone.

and now “navigator is not defined”

node_modules/@aws-amplify/analytics/dist/aws-amplify-analytics.js:38103:24

Confirmed working using @aws-amplify/api@^1.2.4-unstable.3 and @aws-amplify/auth@^1.4.4-unstable.3.

not working on me

@aws-amplify/core/dist/aws-amplify-core.js:10:4

my version is 1.2.4-unstable.5

I am seeing the same error when trying to run a next js app.

[ error ] ReferenceError: window is not defined
    at Object.<anonymous> (.../node_modules/@aws-amplify/analytics/dist/aws-amplify-analytics.js:10:4)
    at Module._compile (internal/modules/cjs/loader.js:868:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)
    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)
    at Object.<anonymous> (.../node_modules/@aws-amplify/analytics/index.js:6:19)
    at Module._compile (internal/modules/cjs/loader.js:868:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)
    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)
    at Object.<anonymous> (.../node_modules/aws-amplify/lib/index.js:15:19)
    at Module._compile (internal/modules/cjs/loader.js:868:30)

aws-amplify@1.2.2 in package.json