错误 - 此命令只能在 CLI 项目内运行 [英] Error - This command can only be run inside of a CLI project

查看:13
本文介绍了错误 - 此命令只能在 CLI 项目内运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个名为 portal 的 ionic 3 项目.我需要创建一个名为 user 的服务,但我不断收到上述错误.这些是我遵循的步骤:

I am working on an ionic 3 project with the name portal. I need to create a service called user but i keep getting the above error. These are the steps i followed:

cd portal 
npm install -g angular-cli@latest
npm install
ng g service user

然后我得到错误 此命令只能在 CLI 项目中运行.我注意到 angular-cli 没有被添加到我在 package.json 中的依赖项列表中,也没有在节点模块目录中的 @angular 下有 cli 目录.我尝试了两次安装 angular-cli,但错误仍然存​​在.已经坚持了很长时间,任何帮助都非常感谢.

Then i get the error This command can only be run inside of a CLI project. I noticed that angular-cli is not getting added to my dependency list in package.json nor do i have the cli directory under @angular in the node modules directory. I tried the install angular-cli twice but the error persists. Have been stuck with it for a long time any help is really appreciated.

推荐答案

好吧,让我写一个答案,而不是评论.

Ok let me, instead of commenting, write an answer.

发生错误是因为您在不是由 Angular CLI 生成的项目中使用 Angular CLI,因此缺少配置文件.

The error occurs because you're using the Angular CLI in a project which isn't generated by the Angular CLI, thus missing configuration files.

由于您说您有一个 ionic 3 应用程序,因此您不需要 angular CLI.

Since you're stating that you have an ionic 3 application, you don't need the angular CLI.

第 1 步:创建项目(你可能已经做过这个)

Step 1: create project (you probably have done this one)

ionic start portal blank  

第 2 步:进入您的项目

Step 2: go into your project

cd portal

第 3 步:(npm install 已经完成,只需生成一个服务)

Step 3: (npm install is already done, just generate a service)

ionic generate provider user

这篇关于错误 - 此命令只能在 CLI 项目内运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆