next.js tutorial Chapter 1 produces [TypeError: localStorage.getItem is not a function]
Unanswered
Transvaal lion posted this in #help-forum
Transvaal lionOP
I'm going through the next.js tutorials and on Chapter 1, when I type
an error:
[TypeError: localStorage.getItem is not a function]
This results in a 500: Internal Server Error on my browser.
I previously had another next.js application running in another terminal, and had stopped it. I'm wondering if there is some residual cruft that is causing this error when I try to run the first example? I created the example with:
npx create-next-app@latest nextjs-dashboard --example "https://github.com/vercel/next-learn/tree/main/dashboard/starter-example" --use-pnpm
pnpm dev, I am gettingan error:
[TypeError: localStorage.getItem is not a function]
This results in a 500: Internal Server Error on my browser.
I previously had another next.js application running in another terminal, and had stopped it. I'm wondering if there is some residual cruft that is causing this error when I try to run the first example? I created the example with:
npx create-next-app@latest nextjs-dashboard --example "https://github.com/vercel/next-learn/tree/main/dashboard/starter-example" --use-pnpm
3 Replies
Transvaal lionOP
Here is a partial output:
➜ nextjs-dashboard git:(main) pnpm run dev
▲ Next.js 15.3.2 (Turbopack)
- Local: http://localhost:3000
- Network: http://192.168.0.208:3000
✓ Starting...
✓ Ready in 713ms
○ Compiling / ...
✓ Compiled / in 527ms
(node:97048) Warning:
(Use
⨯ [TypeError: localStorage.getItem is not a function] {
digest: '2336292967'
}
[TypeError: localStorage.getItem is not a function]
⨯ [TypeError: localStorage.getItem is not a function] { page: '/' }
✓ Compiled /_error in 453ms
[TypeError: localStorage.getItem is not a function]
[TypeError: localStorage.getItem is not a function]
⨯ [TypeError: localStorage.getItem is not a function]
⨯ [TypeError: localStorage.getItem is not a function]
[TypeError: localStorage.getItem is not a function]
⨯ unhandledRejection: [TypeError: localStorage.getItem is not a function]
⨯ unhandledRejection: [TypeError: localStorage.getItem is not a function]
[TypeError: localStorage.getItem is not a function]
[TypeError: localStorage.getItem is not a function]
⨯ [TypeError: localStorage.getItem is not a function]
[TypeError: localStorage.getItem is not a function] { page: '/' }
[TypeError: localStorage.getItem is not a function]
⨯ unhandledRejection: [TypeError: localStorage.getItem is not a function]
⨯ unhandledRejection: [TypeError: localStorage.getItem is not a function]
GET / 500 in 1663ms
GET / 500 in 19ms
✓ Compiled /_not-found/page in 320ms
⨯ [TypeError: localStorage.getItem is not a function] {
digest: '2336292967'
}
➜ nextjs-dashboard git:(main) pnpm run dev
@ dev /Users/digitalmonkey/reactTutorial/nextjs-dashboard
next dev --turbopack
▲ Next.js 15.3.2 (Turbopack)
- Local: http://localhost:3000
- Network: http://192.168.0.208:3000
✓ Starting...
✓ Ready in 713ms
○ Compiling / ...
✓ Compiled / in 527ms
(node:97048) Warning:
--localstorage-file was provided without a valid path(Use
node --trace-warnings ... to show where the warning was created)⨯ [TypeError: localStorage.getItem is not a function] {
digest: '2336292967'
}
[TypeError: localStorage.getItem is not a function]
⨯ [TypeError: localStorage.getItem is not a function] { page: '/' }
✓ Compiled /_error in 453ms
[TypeError: localStorage.getItem is not a function]
[TypeError: localStorage.getItem is not a function]
⨯ [TypeError: localStorage.getItem is not a function]
⨯ [TypeError: localStorage.getItem is not a function]
[TypeError: localStorage.getItem is not a function]
⨯ unhandledRejection: [TypeError: localStorage.getItem is not a function]
⨯ unhandledRejection: [TypeError: localStorage.getItem is not a function]
[TypeError: localStorage.getItem is not a function]
[TypeError: localStorage.getItem is not a function]
⨯ [TypeError: localStorage.getItem is not a function]
[TypeError: localStorage.getItem is not a function] { page: '/' }
[TypeError: localStorage.getItem is not a function]
⨯ unhandledRejection: [TypeError: localStorage.getItem is not a function]
⨯ unhandledRejection: [TypeError: localStorage.getItem is not a function]
GET / 500 in 1663ms
GET / 500 in 19ms
✓ Compiled /_not-found/page in 320ms
⨯ [TypeError: localStorage.getItem is not a function] {
digest: '2336292967'
}
Transvaal lionOP
Ok, it looks like downgrading node to version 24 from 25.2.1 fixed the issue for me.
So node.js 25.2.1 introduces some kind of incompatibility.