ERROR Sorry! ionic serve can only be run in an Ionic project directory

37,695

Solution 1

I had a similar issue where an older Ionic V1 application was originally written using a Visual Studio 2015 project. I wanted to use the Ionic CLI to build the application instead. This is what I did as of Ionic CLI version 4.0.6 to get past the "can only be run in an Ionic project directory" error.

  1. Create ionic.config.json file.
  2. Update the new file with the following code:

    {
        "name": "AppName",
        "integrations": {
            "gulp": {},
            "cordova": {},
         },
         "type": "ionic1",
         "watchPatterns": [
             "scss/**/*",
             "www/**/*",
             "!www.lib/**/*",
             "!www/**/*.map"
          ]
    }
  1. Run "npm install ionic -g"
  2. Run "ionic cordova build ios" or "ionic cordova build android" depending on what you want.

Solution 2

i have also the some problem when i have updated ionic/cordova and have created my first app with ionic 3, after that i can't run my older ionic 1 app. Below the steps which i have done for run my ionic 1 app

1.Go to the newly created project (with Ionic 3.*) and open package.json

2.There should be line like "@ionic/cli-plugin-ionic-angular"

3.Copy this line to package.json of your Ionic v1 project(on V2 app can be other plugins starting with cli-plugin-.. as well, you can move these too)

4.Change the ionic-angular to ionic1 like this "@ionic/cli-plugin-ionic1"

5.Run npm install in your v1 project folder

6.Rename the file ionic.project to ionic.config.json

7.Then try ionic serve

hope your v1 app will be started

Solution 3

If you get ERROR Sorry! ionic serve can only be run in an Ionic project directory, make sure you create an empty "www" directory at the project root. If cordova does not find a "www" directory, it will cry out that error.

To create a project with the latest ionic cli, you will need to add the flag --type ionic1 at the end to make sure that you grab Ionic 1 and not the latest ionic version.

example: ionic start myApp tabs --type ionic1

This will generate a new project with ionic v1. Reference: https://github.com/driftyco/ionic-cli/blob/master/README.md#ionic-1

Solution 4

It's because your project is not an Ionic project. Running the following will solve the problem:

ionic init
Share:
37,695
thanveer pu
Author by

thanveer pu

Updated on July 09, 2022

Comments

  • thanveer pu
    thanveer pu almost 2 years

    I am using ionic 1 project. After update cordova i get "[ERROR] Sorry! ionic serve can only be run in an Ionic project directory" error message in ionic 1 project. When i try to create new ionic project by "ionic start myApp tabs" It build me new project and its ionic 2. How can i go back to ionic 1 and run my old project ?