Vite:Error: Cannot find module ‘worker_threads‘

created at 10-02-2021 views: 424

Follow the official website vite startup steps

$ npm init vite@latest

$ npm run dev

then got the error

Error: Cannot find module 'worker_threads' 


Vite requires Node.js version >= 12.0.0.

Check my own Node version

$ node -v

So you can upgrade the Node version, here use nvm to manage the Node version

# View available versions
$ nvm ls-remote
# Install the latest version 12
$ nvm install 12.22.6
# Switch to the latest version
$ nvm alias default 12.22.6
$ node -v
created at:10-02-2021
edited at: 10-02-2021: