ionic-team / ionic-cli

The Ionic command-line interface
MIT License
2k stars 653 forks source link

Current working directory is not a Cordova based project #935

Closed jgw96 closed 7 years ago

jgw96 commented 8 years ago

From @reynoldbhatia on April 14, 2016 20:16

I have everything setup but when I try running ionic platform add android

it just gives me an error saying Current working directory is not a Cordova based project

image

Copied from original issue: driftyco/ionic#6174

jgw96 commented 8 years ago

From @dhirajb1989 on April 15, 2016 2:11

Is config.xml present there???

jgw96 commented 8 years ago

From @reynoldbhatia on April 15, 2016 13:58

Yes there is.

jgw96 commented 8 years ago

@reynoldbhatia Hello! Sorry your having an issue getting started with your ionic app! Did you create this app with ionic start or did you git clone it from github? Also, do you have cordova installed?

jgw96 commented 8 years ago

From @reynoldbhatia on April 15, 2016 15:28

I created it using ionic start. And yes, I have Cordova installed. Cordova create also works. The project created with Cordova create also gives the same error when I try adding the platform.

jgw96 commented 8 years ago

@reynoldbhatia thanks for the info! So im gonna defer this issue over to the ionic-cli repo as the guys over there will be able to help you better with this issue than i can.

tlancina commented 8 years ago

Could you post the output of ionic info please?

reynoldbhatia commented 8 years ago

I am re-installing everything. I'll send it once it is done. Thanks.

reynoldbhatia commented 8 years ago

capture

The output to ionic info @tlancina

reynoldbhatia commented 8 years ago

Also, If I run cordova platform add android from inside the project folder, it works fine. But ionic platform add android gives the same error.

tlancina commented 8 years ago

Could you run it with the --verbose flag and post the out put please? ionic platform add android --verbose, thanks!

On Tue, Apr 19, 2016 at 10:20 AM Reynold Bhatia notifications@github.com wrote:

Also, If I run cordova platform add android from inside the project folder, it works fine. But ionic platform add android gives the same error.

— You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic-cli/issues/935#issuecomment-211975724

reynoldbhatia commented 8 years ago

capture

reynoldbhatia commented 8 years ago

I would like to add.... I have 2 other systems running on Windows 8.1 and Windows 10 which work fine. The system I am working on currently is Windows 7. Just in case, if the operating system needs something more to be done while setup.

jgw96 commented 8 years ago

@reynoldbhatia what version of npm are you using? npm 2 or npm 3?

reynoldbhatia commented 8 years ago

2.15.1

jgw96 commented 8 years ago

Ahh, could you try updating to npm 3? We've seen a couple of issues related to npm 2. To update npm you run npm install -g npm.

jgw96 commented 8 years ago

Oh and then remove your node modules and then run npm install again.

reynoldbhatia commented 8 years ago

I did as you said. It did not work. Still giving me the same error.

reynoldbhatia commented 8 years ago

capture

Still getting the same error.

sbesselsen commented 8 years ago

For posterity: usually the solution is to make sure there's a www/ directory inside the root directory.

hoodaajay99 commented 8 years ago

mkdir www in your project folder and it works well.

dniccum commented 8 years ago

@hoodaajay99 this solved my issue as well.

warent commented 8 years ago

@sbesselsen that was it

westonganger commented 8 years ago

+1 mkdir www

fiznool commented 7 years ago

This was the same issue for me.

I originally created an Ionic 2 app with ionic start on one machine, and committed and pushed to github. Then, I pulled down the code on a second machine, and tried to run ionic platform add ios. Since the www folder is gitignored, it isn't committed to github, therefore the second machine's cloned codebase not contain a www folder, and the command fails.

As mentioned, one solution is to mkdir www. Another solution is to first run ionic serve on the second machine, which will automatically create the www folder. Afterwards, ionic platform add commands will work.

VovanSuper commented 7 years ago

yep, "./www" ... :)

aaronksaunders commented 7 years ago

if it is required to run, then why is it added to the gitignore file?

dericeira commented 7 years ago

@aaronksaunders That's the million-dollar question.

fiznool commented 7 years ago

@aaronksaunders probably for the same reason that _nodemodules is part of .gitignore. These files are needed to run the app, but committing them would cause unnecessarily large and complex commits. Every time the files in www are built, the main.js file will be treated as a different file by source control. You wouldn't want that consuming your commit logs.

aaronksaunders commented 7 years ago

@fiznool - very thorough explanation however the one point i would disagree with is that the exclusion of the folder causes errors and the exclusion of node_modules does not so IMHO the comparison is not appropriate

lufias commented 7 years ago

should've added .gitkeep file or any other way to ensure the directory exist even if the content is never to be committed.

www/* !www/.gitkeep

ctodea commented 7 years ago

folder www is genereted every time you ionic serve

lufias commented 7 years ago

@Frutal1ty that is if you use ionic serve.. OP wants to deploy the app on device by adding in the android platform.. and calling run instead of serve.. that's when things doesn't work as it should.. no www folder were created..

penglipurlara10 commented 7 years ago

I have the same problem, but i'm currently using phonegap because i'm new to mobile app development

utsav-gupta commented 7 years ago

I followed this whole discussion which helped me. I have my 2 cents which could help others. I would suggest it would be good idea for ionic to create www if it is not there instead of error that "this is not a cordova directory". Somebody asked above why is www directry ignored if it is needed by ionic. The above fix would solve this problem too as we will not hav to upload www to git that way..

alexunjm commented 7 years ago

hi everybody! check if www folder exist. If it doesn't exist, maybe you cloned your repo like me I solved doing npm install, because the node_modules aren't in my repo, and finally, run "ionic serve" for check that my project is ok. With "ionic serve" command, www folder is created and now you can run "ionic add platform android" command

Rombersoft commented 7 years ago

I'm crying. I have same problem and directory www exists in my projects.

khushbooInheritx commented 7 years ago

make sure you are firing command from the root directory(write inside cmd: cd yourRootFolder) and www folder exists inside it.

Rombersoft commented 7 years ago

I know reason. It is that I've created project using Intel xdk not Cordova command prompt.

03 апр. 2017 г. 8:52 пользователь "khushbooInheritx" < notifications@github.com> написал:

make sure you are firing command from the root directory(write inside cmd: cd yourRootFolder) and www folder exists inside it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/driftyco/ionic-cli/issues/935#issuecomment-291054268, or mute the thread https://github.com/notifications/unsubscribe-auth/ASrdokGa7IA4W9u4dkAc2P8ampKgwfWEks5rsIkKgaJpZM4IIbqG .

xbojer commented 7 years ago

As stated before - problem is mostly missing www directory because of wrong .gitignore file... This should be fixed. Manually creating www directory or starting ionic serve before for example ionic state restore is NOT a solution at all...

santiq commented 7 years ago

I had the same issue with my circle-ci build What I did was add mkdir www before run ionic cordova platform add android

imhoffd commented 7 years ago

CLI 3.1.0 automatically creates the www directory. Please update.

mikermcneil commented 7 years ago

As a datapoint, I'm still seeing this error when I run ionic run android --device.

For context, I have a www/ folder and the following system info:

On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean

∑ ionic info
******************************************************
 Dependency warning - for the CLI to run correctly,      
 it is highly recommended to install/upgrade the following:     

 Install ios-sim to deploy iOS applications.`npm install -g ios-sim` (may require sudo)
 Install ios-deploy to deploy iOS applications to devices.  `npm install -g ios-deploy` (may require sudo)

******************************************************

Your system information:

Cordova CLI: 7.0.1 
Ionic Framework Version: 3.1.0
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.5
ios-deploy version: Not installed
ios-sim version: Not installed
OS: macOS Sierra
Node Version: v7.9.0
Xcode version: Xcode 8.2.1 Build version 8C1002

******************************************************
 Dependency warning - for the CLI to run correctly,      
 it is highly recommended to install/upgrade the following:     

 Install ios-sim to deploy iOS applications.`npm install -g ios-sim` (may require sudo)
 Install ios-deploy to deploy iOS applications to devices.  `npm install -g ios-deploy` (may require sudo)

******************************************************
∑ 
∑ 
∑ ls -la .
total 48
drwxr-xr-x   15 mikermcneil  staff    510 Jun  7 08:37 .
drwxr-xr-x   21 mikermcneil  staff    714 Jun  7 08:33 ..
-rw-r--r--    1 mikermcneil  staff      0 Apr 27 14:49 .gitkeep
-rw-r--r--    1 mikermcneil  staff   5885 Apr 27 17:07 config.xml
drwxr-xr-x    3 mikermcneil  staff    102 Apr 27 17:07 hooks
-rw-r--r--    1 mikermcneil  staff     74 Apr 27 17:07 ionic.config.json
drwxr-xr-x  512 mikermcneil  staff  17408 May  9 20:15 node_modules
-rw-r--r--    1 mikermcneil  staff   1424 May  1 12:58 package.json
drwxr-xr-x    5 mikermcneil  staff    170 Apr 29 20:49 platforms
drwxr-xr-x   10 mikermcneil  staff    340 Apr 27 17:07 plugins
drwxr-xr-x    6 mikermcneil  staff    204 Apr 27 17:07 resources
drwxr-xr-x@  12 mikermcneil  staff    408 Jun  7 08:37 src
-rw-r--r--    1 mikermcneil  staff    465 Apr 27 17:07 tsconfig.json
-rw-r--r--    1 mikermcneil  staff    178 Apr 27 17:07 tslint.json
drwxr-xr-x    7 mikermcneil  staff    238 Apr 29 18:26 www
∑ 

EDIT: Seems like this might be a kind of generic error message -- in my case, it seemed to be related to the fact that I didn't have ADB enabled on the android device I had connected (a Kindle Fire).

imhoffd commented 7 years ago

Ionic CLI Version: 2.2.3

You are still on the old version. Please update.

dgaurav-163 commented 7 years ago

Can you please first try "ionic build serve" then same error will occur L18: this.platform.ready().then(() => { L19: let browser = new InAppBrowser("https://www.techiediaries.com",'_blank');

Error: No platforms added to this project. Please use cordova platform add <platform>. then call "cordova platform add ".

It will work

Reegan01 commented 7 years ago

simply add ionic in front of cordova plugin add ... or cordova platform add android

So finally it look like ionic cordova platform add...

For this you must have latest ionic version

Rand-om commented 6 years ago

I had the same issue, but I used "ionic cordova platform add android", and it started to work perfectly!

agenda

mark-vn commented 6 years ago

@Reegan01's worked for me with Ionic CLI v3.18.0 👍

soumyarout commented 6 years ago

If anyone is getting same error in adding adding plugins use the command like this

ionic cordova plugin add cordova-plugin-<plugin-name>

imhoffd commented 6 years ago

The root of this issue is the following files must exist for the Cordova CLI to detect it as a Cordova project:

The Ionic CLI can detect and fix some problems with these files (all the ionic cordova ... commands run these checks), but sometimes it's not enough and you'll need to fix something manually.

Locking this issue--it's ancient.