Error when running cookies() from next/headers - Error: (0 , _requestasyncstorageexternal.getExpectedRequestStore) is not a function
caioalmeida12 opened this issue · 3 comments
Link to the code that reproduces this issue
https://github.com/caioalmeida12/sisref-v2-dashboard/tree/110-instalar-docker
To Reproduce
- Build the dockerfile: docker build -t sisref-v2-dashboard .
- Run the docker container: docker run --rm -it -p 3000:3000/tcp sisref-v2-dashboard:latest
- Access the page: http://localhost:3000
Current vs. Expected behavior
Currently, instead of being able to access the page, it crashes upon request to the / route. It compiles the middlewares perfectly, tho.
Provide environment information
C:\Users\caiod\AppData\Roaming\nvm\v12.22.12\node_modules\npm\lib\cli\validate-engines.js:31
throw err
^
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (C:\Users\caiod\AppData\Roaming\nvm\v12.22.12\node_modules\npm\node_modules\fs-minipass\lib\index.js:136:4)
at Module._compile (node:internal/modules/cjs/loader:1434:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)
at Module.load (node:internal/modules/cjs/loader:1249:32)
at Module._load (node:internal/modules/cjs/loader:1065:12)
at Module.require (node:internal/modules/cjs/loader:1271:19)
at require (node:internal/modules/helpers:123:16)
at Object.<anonymous> (C:\Users\caiod\AppData\Roaming\nvm\v12.22.12\node_modules\npm\lib\utils\log-file.js:3:20)
at Module._compile (node:internal/modules/cjs/loader:1434:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)
Node.js v22.2.0
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Enterprise
Available memory (MB): 30614
Available CPU cores: 12
Binaries:
Node: 22.2.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 14.2.3 // Latest available version is detected (14.2.3).
eslint-config-next: N/A
react: 18.3.1
react-dom: 18.3.1
typescript: 5.4.5
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Module Resolution, Navigation, Runtime
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
I tested running on Node 20.13 LTS, but didnt work as well.
I cant figure out why my NPM base command wont work, tho. I've been falling back to bun, which works perfectly. Might be related.
I got the same error after migrating from NextJS 13 to NextJS 14 and when running lighthouse. But I cannot replicate locally
Hello, I faced the same error, and I just solved as follows:
First, open a cmd in your sisref-v2-dashboard folder, and type :
- npm uninstall next
- npm uninstall react
- npm uninstall react-dom
Then, in sisref-v2-dashboard/package.json, add your dependencies “next”, “react” & “react-dom” to exactly the same version as those in sisref-v2-dashboard/sisref-v2-dashboard-client/package.json, so your sisref-v2-dashboard/package.json sould look like :
{
"dependencies": {
"@microsoft/eslint-formatter-sarif": "2.1.7",
"@radix-ui/react-form": "^0.0.3",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-tooltip": "^1.0.7",
"@types/jsonwebtoken": "^9.0.6",
"eslint": "8.57.0",
"jsonwebtoken": "^9.0.2",
"next": "14.1.4",
"react": "^18",
"react-dom": "^18",
"react-loading-skeleton": "^3.4.0",
"slide-element": "^2.3.1",
"typescript": "^5.0.0"
},
"name": "sisref-v2-dashboard",
"module": "index.ts",
"type": "module",
"devDependencies": {
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@eslint/js": "^8.57.0",
"@types/bun": "latest",
"cz-conventional-changelog": "^3.3.0",
"eslint-plugin-react": "^7.34.1",
"globals": "^15.0.0",
"husky": "^9.0.11",
"typescript-eslint": "^7.7.0"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"scripts": {
"cm": "cz",
"dev": "cd sisref-v2-dashboard-client; bun dev",
"lint": "bun eslint ./sisref-v2-dashboard-client/src/ --fix",
"lint-ci": "npx eslint ./sisref-v2-dashboard-client/src/ --format @microsoft/eslint-formatter-sarif > eslint-results.sarif"
}
}
Finally, you just need to npm install
, you are good to go !
Hello, I faced the same error, and I just solved as follows:
First, open a cmd in your sisref-v2-dashboard folder, and type :
- npm uninstall next
- npm uninstall react
- npm uninstall react-dom
Then, in sisref-v2-dashboard/package.json, add your dependencies “next”, “react” & “react-dom” to exactly the same version as those in sisref-v2-dashboard/sisref-v2-dashboard-client/package.json, so your sisref-v2-dashboard/package.json sould look like :
{ "dependencies": { "@microsoft/eslint-formatter-sarif": "2.1.7", "@radix-ui/react-form": "^0.0.3", "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-navigation-menu": "^1.1.4", "@radix-ui/react-tooltip": "^1.0.7", "@types/jsonwebtoken": "^9.0.6", "eslint": "8.57.0", "jsonwebtoken": "^9.0.2", "next": "14.1.4", "react": "^18", "react-dom": "^18", "react-loading-skeleton": "^3.4.0", "slide-element": "^2.3.1", "typescript": "^5.0.0" }, "name": "sisref-v2-dashboard", "module": "index.ts", "type": "module", "devDependencies": { "@commitlint/cli": "^19.2.1", "@commitlint/config-conventional": "^19.1.0", "@eslint/js": "^8.57.0", "@types/bun": "latest", "cz-conventional-changelog": "^3.3.0", "eslint-plugin-react": "^7.34.1", "globals": "^15.0.0", "husky": "^9.0.11", "typescript-eslint": "^7.7.0" }, "peerDependencies": { "typescript": "^5.0.0" }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog" } }, "scripts": { "cm": "cz", "dev": "cd sisref-v2-dashboard-client; bun dev", "lint": "bun eslint ./sisref-v2-dashboard-client/src/ --fix", "lint-ci": "npx eslint ./sisref-v2-dashboard-client/src/ --format @microsoft/eslint-formatter-sarif > eslint-results.sarif" } }Finally, you just need to
npm install
, you are good to go !
Just came here to say THANK YOU VERY MUCH!
Not only did this solve this issue's error, but also fixed another ghostly unsolved one: this dude right here - error: Failed due to error: bunsh: No such file or directory running bun dev
Can't believe it was that simple of a fix.
But its as they say: victory is in the simple things.
Just as i reminder, thank you @Ashka59!