Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 ?

like image 975
thanveer pu Avatar asked May 19 '17 09:05

thanveer pu


People also ask

Can only be run in an ionic project directory?

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.

How do you serve an ionic app?

By default, ionic serve boots up a development server on localhost . To serve to your LAN, specify the --external option, which will use all network interfaces and print the external address(es) on which your app is being served. Try the --lab option to see multiple platforms at once. ionic serve uses the Angular CLI.

What is ionic config JSON?

ionic/config. json , and project configuration files, usually at the project's root directory as ionic. config. json . The CLI provides commands for setting and printing config values from project config files and the global CLI config file.


2 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.
like image 130
Brett Whittington Avatar answered Oct 21 '22 08:10

Brett Whittington


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

like image 29
Hayk Abrahamyan Avatar answered Oct 21 '22 08:10

Hayk Abrahamyan