Skip to content

Node.js 25: localStorage.getItem is not a function in MSW #2624

@qjatjs123123

Description

@qjatjs123123

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 20 or higher

Node.js version

v25.1.0

Reproduction repository

https://github.com/qjatjs123123/reproduction-msw-localStorage-bug

Reproduction steps

  • error test
clone repo

npm install

nvm use 25.1.0

npm run dev
  • success test
clone repo

npm install

nvm use 18.18.2

npm run dev

It seems that the issue reported in #2612
is still unresolved.

Current behavior

unhandledRejection:  TypeError: localStorage.getItem is not a function
    at eval (webpack-internal:///(rsc)/./mocks/server.ts:6:61)
    at <unknown> (rsc)/./mocks/server.ts (C:\Users\Hong\Desktop\study\reproduction-msw-localStorage-bug\.next\server\_rsc_mocks_server_ts.js:20:1)
    at async eval (app\layout.tsx:7:24)

Expected behavior

Should not use localStorage on Node.js 25

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds:triageIssues that have not been investigated yet.scope:nodeRelated to MSW running in Node

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions