Solve the engine “node” is incompatible with this module — Fix the create command
This is assumed you are on the Mac machine
You can check the Node.js version with the following command
node -v
16.x.x
Then you use the homebrew to remove the Node.js
brew remove node
Then you search for the version that you targeting
brew search node
node@14
node@16
node@18
node@20
You should install the latest long term support version (LTS version)
At Feb 2024, it is Node.js 20 so I install it by
brew install node@20
Don’t forget to link it by the command suggested by homebrew.
Adding this line to the end of ~/.zshrc
export PATH="/opt/homebrew/opt/node@20/bin:$PATH"
Then source the file
source ~/.zshrc
Here you go with the Node version you are expecting
node -v
v20.11.1
Bonus: Fixing create command
If there is an error on the create command, you can also fix it by upgrading it after upgrading the Node.js version.
yarn global upgrade
Then the yarn create command should be fine. For example,
yarn create vite demo-ptg --template react-ts