Solved successfully.
Environment
- Windows 11
- Node.js 20
- pnpm
I encountered this error when updating the Nuxt version, whether upgrading to 3.19 or 4.0. After searching, I found that this is not a Nuxt issue, as other projects also encountered this error during installation.
Solution
- Install nvm, as my system is Windows 11, I installed nvm-windows.
- Use nvm to install the latest stable version of Node.js, I installed node 22.
- Switch to node 22. Delete the node_modules directory, delete pnpm-lock.yaml, and reinstall dependencies.
- On Windows, you can install and use rimraf to delete the node_modules directory.