You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular项目node_modules缺失无法运行的问题及解决办法

Angular新项目创建后缺失node_modules,ng serve启动失败

问题描述

执行ng new <project_name>创建新项目后,node_modules文件夹未自动生成,运行ng serve时终端报错:

Node packages may not be installed. Try installing with 'npm install'.
Error: Could not find the '@angular-devkit/build-angular:dev-server' builder's node package.

已尝试的操作

先后执行以下命令,未解决问题:

npm uninstall --save-dev @angular/cli
npm uninstall --save @angular/cli
npm cache clean --force
npm install --save @angular/cli
npm install

其中npm install仅输出:

up to date in 662ms

在已有node_modules的其他项目中执行npm install,终端显示类似内容但无新增依赖:

changed 36 packages in 14s
2 packages are looking for funding

解决方案

最终通过降级npm版本解决问题:
执行命令:

npm install -g npm@7

之后npm install恢复正常,node_modules文件夹及所有依赖可正常生成。注意后续可能出现依赖冲突问题。

内容的提问来源于stack exchange,提问作者lys_18

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 09:34:55