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

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

问题描述

我正在开发一个名为portal的离子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.

由于您声明自己拥有离子3应用程序,因此您不需要角度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步:进入你的项目

cd portal

第3步: (已完成npm安装,只需生成服务)

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

ionic generate provider user

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

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