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

Viewed 40660

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 ?

6 Answers

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.

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

ionic init

Whenever there's this particular error, do make sure that you are in an Ionic Project directory. If you're not, go to the directory and run the command, it'll work. Hope it helps.

Related