Vite:Error: Cannot find module ‘worker_threads‘

简介: Vite:Error: Cannot find module ‘worker_threads‘

按照官网vite启动步骤


$ npm init vite@latest
$ npm run dev

报错

Error: Cannot find module 'worker_threads'

原因是:


Vite 需要 Node.js 版本 >= 12.0.0。

查看我自己的Node版本


$ node -v
v10.16.0

所以升级Node版本即可,这里使用nvm管理Node版本


# 查看可用版本
$ nvm ls-remote
# 安装最新的12版
$ nvm install 12.22.6
# 切换到最新版本
$ nvm alias default 12.22.6
$ node -v
v12.22.6
相关文章
|
JavaScript
Syntax Error: Error: Cannot find module ‘node-sass‘
Syntax Error: Error: Cannot find module ‘node-sass‘
337 0
|
移动开发 前端开发
RN运行项目Error:Unable to resolve module
RN运行项目Error:Unable to resolve module
1100 0
RN运行项目Error:Unable to resolve module
|
7月前
报错/ ./node_modules/axios/lib/platform/index.js Module parse failed: Unexpected token (5:2)怎么解决?
报错/ ./node_modules/axios/lib/platform/index.js Module parse failed: Unexpected token (5:2)怎么解决?
npm 启动报错 解决 events.js:174 throw er; // Unhandled 'error' event 的报错问题
npm 启动报错 解决 events.js:174 throw er; // Unhandled 'error' event 的报错问题
npm 启动报错 解决 events.js:174 throw er; // Unhandled 'error' event 的报错问题
|
7月前
Angular启动/node_modules/@types/node/index.d.ts (20,1): Invalid ‘reference‘ directive syntax.
Angular启动/node_modules/@types/node/index.d.ts (20,1): Invalid ‘reference‘ directive syntax.
80 2
|
7月前
Module build failed (from ./node_modules/eslint-loader/index.js)
Module build failed (from ./node_modules/eslint-loader/index.js)
195 0
Module build failed (from ./node_modules/eslint-loader/index.js)
node Express.js node:internal/modules/cjs/loader:988 throw err; ^ Error: Cannot find module ‘
node Express.js node:internal/modules/cjs/loader:988 throw err; ^ Error: Cannot find module ‘
1124 0
node Express.js node:internal/modules/cjs/loader:988 throw err; ^ Error: Cannot find module ‘
|
资源调度 JavaScript Windows
yarn create vite的时候,报错:SyntaxError: Unexpected token ‘.‘ at Loader.moduleStrategy (internal/modules/
yarn create vite的时候,报错:SyntaxError: Unexpected token ‘.‘ at Loader.moduleStrategy (internal/modules/
667 0
打包报错Error: ‘default‘ is not exported by node_modules/qs/lib/index.js
打包报错Error: ‘default‘ is not exported by node_modules/qs/lib/index.js
275 0
error: Two output files share the same path but have different contents: node_modules\.vite\..xxx.js
error: Two output files share the same path but have different contents: node_modules\.vite\..xxx.js
738 0
error: Two output files share the same path but have different contents: node_modules\.vite\..xxx.js