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
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.
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.
Since you're stating that you have an ionic 3 application, you don't need the angular CLI.
Step 1: create project (you probably have done this one)
ionic start portal blank
Step 2: go into your project
cd portal
Step 3: (npm install is already done, just generate a service)
ionic generate provider user
Your steps must be in this order:
1) Install angular globally
npm install -g angular-cli@latest
2) Create the app at a directory location
ng new portal
3) Go into that folder
cd .\portal\
4) Install node modules
npm install
5) Generate service
ng g service user
If your commands are not in this order, you will have an error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With