问题描述
我在全球安装了最新的 angular-cli,我的项目正在成功构建.
I had the latest angular-cli installed globally and my project was building successfully.
在阅读针对另一个问题的建议解决方案时,(https://github.com/angular/angular-cli/issues/917) 我卸载了全局 angular-cli 并将其安装为开发依赖项.
While reading a suggested solution for another issue, (https://github.com/angular/angular-cli/issues/917) I uninstalled the global angular-cli and installed it as a dev-dependency.
另一个问题没有解决,所以我卸载了 dev-dependency 并再次全局重新安装了 angular-cli.现在,当我尝试执行 ng build 时出现错误:
That other issue wasn't solved so I uninstalled the dev-dependency and reinstalled angular-cli globally once again.Now when I try to do an ng build I'm getting the error:
您必须在 angular-cli 项目中才能使用构建命令
我的 angular-cli 版本没有改变.为什么我的项目没有被识别为 angular-cli 项目?
My angular-cli version did not change. Why isn't my project being recognised as an angular-cli project??
推荐答案
好的,找到了.
package.json 必须包含对 angular-cli 的依赖.
package.json must contain a dependency to angular-cli.
当我卸载本地 angular-cli 时,npm 也删除了依赖项.
When I uninstalled my local angular-cli, npm also removed the dependency entry.
这篇关于您必须在 angular-cli 项目中才能在重新安装 angular-cli 后使用 build 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!