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

无法查看Angular版本:执行ng --version命令提示node_modules不存在

解决ng --version报错找不到node_modules的问题

问题描述

Node版本10.14.1,npm版本6.4.1,已安装Angular 7.0.3,但执行ng v时出现以下错误:

C:\Users\indhumadhi.k>ng v
ENOENT: no such file or directory, scandir 'C:\Users\indhumadhi.k\node_modules'
Error: ENOENT: no such file or directory, scandir 'C:\Users\indhumadhi.k\node_modules'
at Object.readdirSync (fs.js:783:3)
at VersionCommand.run (C:\Users\indhumadhi.k\AppData\Roaming\npm\node_modules@angular\cli\commands\version-impl.js:48:41)
at VersionCommand.validateAndRun (C:\Users\indhumadhi.k\AppData\Roaming\npm\node_modules@angular\cli\models\command.js:123:31)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

解决方案

  • 切换到Angular项目根目录再执行命令:ng --version默认会读取当前目录下的node_modules来获取项目的Angular版本信息,如果你在用户主目录(C:\Users\indhumadhi.k)执行,这里没有项目的node_modules,自然会报错。找到你的Angular项目文件夹,用cd命令进入后再运行ng v。
  • 若在项目目录下仍报错,执行npm install:如果项目的node_modules被误删或未安装完全,这条命令会重新下载并安装所有项目依赖,生成node_modules目录。
  • 查看全局Angular CLI版本:如果只是想确认全局安装的Angular版本,直接执行ng v --global,这条命令不需要依赖项目目录的node_modules,会直接读取全局安装的CLI信息。

内容的提问来源于stack exchange,提问作者Indhumadhi K V

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 07:03:27