【问题标题】:Unable to Find npm install -g @angular/cli@latest in devDependencies无法在 devDependencies 中找到 npm install -g @angular/cli@latest
【发布时间】:2018-04-05 10:19:01
【问题描述】:
ng build 给出一个错误
无法在 devDependencies 中找到 npm install -g @angular/cli@latest。
使用npm start 启动应用程序,但是当我尝试构建文件时,它在 CMD 中给我一条错误消息:
在 devDependencies 中找不到“@angular/cli”。请采取
以下步骤以避免出现问题:“npm install --save-dev
@angular/cli@latest" @angular/compiler-cli 和 typescript 的版本
无法确定。最常见的原因是损坏
npm 安装。请确保您的 package.json 包含两者
@angular/compiler-cli 和 devDependencies 中的 typescript,然后删除
node_modules 和 package-lock.json (如果你有的话)并运行 npm
重新安装。
我按照错误消息中建议的所有步骤进行操作,但它仍然给我相同的消息enter image description here
【问题讨论】:
标签:
node.js
angular
typescript
npm
【解决方案1】:
我遇到了同样的问题,以下步骤帮助我解决了它,
Update package json
from
"angular-cli": "anything"
to
"@angular/cli": "1.0.4"
Deleted node_modules and installed node modules again with
npm install
Change angular-cli.json for
from
"environments": {
"source": "environments/environment.ts"
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
to
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
【解决方案2】:
您的node_modules 似乎有问题。删除 node_modules 和 package-lock.json 并确保在 package.json 中拥有所有依赖项。之后运行 npm install
另一点可能是您没有安装@angular/cli 模块。
就像错误信息中所说的,尝试使用npm install -g @angular/cli安装这个包。