vscod 执行npm build报错:Error: Cannot find module ‘vite‘

复制代码
PS D:\2025\vue> npm run build

> myvueapp@0.0.0 build
> vite build

failed to load config from  D:\2025\vue\vite.config.js
error during build:
Error: Cannot find module 'vite'
Require stack:
- D:\2025\vue\vite.config.js
- D:\npm\node_modules\vite\dist\node\chunks\config.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1421:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1059:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1064:22)
    at Module._load (node:internal/modules/cjs/loader:1227:37)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
    at Module.require (node:internal/modules/cjs/loader:1504:12)
    at require (node:internal/modules/helpers:152:16)
    at Object.<anonymous> (D:\2025\vue\vite.config.js:36:19)
    at Module._compile (node:internal/modules/cjs/loader:1761:14)

解决:

复制代码
直接在终端输入npm install就行

PS D:\2025\vue> npm install
相关推荐
zxcvb1536 分钟前
远程查看本地文档:一条轻量 Web 文件服务的工程化链路
前端·远程查看文档
niucloud-admin16 分钟前
NIUCLOUD PHP SAAS上门家政使用文档:城市管理
java·前端·php
北岛贰32 分钟前
啵啵音乐迎来全新升级!
前端
hkNaruto2 小时前
【AI】基于大模型的AI游戏地图生成、控制方案:AI Native Game Harness 迁移操作手册
前端·人工智能·游戏
IT_陈寒3 小时前
Java序列化踩坑记:对象循环引用让我加班两小时
前端·人工智能·后端
Acro3 小时前
快给macOS 上的Grok Bot换一套皮肤
前端
flash俊杰3 小时前
双引擎 OCR 编排:逐页判定、视觉优先、partial 语义与三层超时
前端
计算机魔术师3 小时前
Reddit 每周被 Google 偷走 100 万次点击,CEO 摊牌了
前端
前端繁华如梦3 小时前
用 React Three Fiber 做一栋能编辑的教学楼数字孪生
前端
前端繁华如梦3 小时前
用 React Three Fiber 做一套智慧医院数字孪生:编辑器、大屏和 BIM 浏览器
前端