For a greater version jump I actually recommend creating a new project and then pasting your source and configuration there.
For usage with Yoeman and Node 22:
Install the new node version, e.g. with Node Version Manager (nvm):
nvm install 22.20.1 # Will be supported until 2027
nvm use 22
Install the required global packages for the new node version:
Execute yoeman in a new folder with your solution name to create your new solution
yo
SharePoint
Webpart
React (or the one you need)
Original project name
Install packages
Adjust and overwrite
config.json (overwrite)
package-solution.json (overwrite)
serve.json (overwrite)
src folder (overwrite)
package.json: "version"
.yo-rc.json: "libraryId"
.eslintrc.js, tsconfig.json (adjust as needed)
Test
gulp build
gulp serve
Test in Browser (Workbench)