[SOLVED] Problem to serve an app in ionic1 with installed Ionic CLI v3


#1

Hi all,

i have developed some times ago an app with ionic v.1 , now on my mac i have installed ioniv v.2, if i enter in directory project ionic v.1 and launch command " ionic serve " i receive this error message:

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

i have tried with a tricks:

  1. Create a new ionic app launching command
ionic start newapp blank --v1
  1. i have copied all contents from /www ionic v.1 app directory in /www new app directory
  2. I have copied directory /plugins from ionic v.1 app to new app directory
  3. I have launched "cordova prepare " and " cordova platform add android "
  4. If i launch command “ionic serve” i see a blank project and not my app

How can i it works again?

Thank you so much.
Regards


#2

No, what you installed was most certainly the Ionic CLI in a version. Please give us the output of ionic info so we know which one exactly you installed.


#3

Hi Sujan12, you’re right i have installed ionic cli, this is my ionic info output

ionic info

global packages:

@ionic/cli-utils : 1.0.0
Cordova CLI      : 7.0.0
Ionic CLI        : 3.0.0

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.0.0
@ionic/cli-plugin-ionic-angular : 1.0.0
Ionic Framework                 : ionic-angular 3.1.1

System:

Node       : v6.10.3
OS         : macOS Sierra
Xcode      : Xcode 8.3.2 Build version 8E2002
ios-deploy : not installed
ios-sim    : not installed

Thank you.


#4

Awesome.

Can you now please post the exact output you get when you run ionic --help and ionic serve in the ionic-v1 project directory you have?

If this doesn’t work (please post the output here anyway!) please run this command to install some stuff the v3 CLI needs for working with Ionic v1 projects:
npm install --save-dev --save-exact @ionic/cli-plugin-ionic1@latest @ionic/cli-plugin-cordova@latest
Then try again to run ionic serve.


#5

after run “ionic --help”

ionic --help
   _             _
  (_)           (_)
   _  ___  _ __  _  ___
  | |/ _ \| '_ \| |/ __|
  | | (_) | | | | | (__
  |_|\___/|_| |_|_|\___|  CLI 3.0.0


  Usage:

    $ ionic <command> [arguments] [options]
    $ ionic <command> --help (for command details)

  Global Commands:

    docs ................ Open the Ionic documentation website
    info ................ Print system/environment info
    login ............... Login with your Ionic ID
    signup .............. Create an Ionic account
    start ............... Create a new project
    telemetry ........... Opt in and out of telemetry

  Project Commands:

    You are not in a project directory.

  Options:

    --verbose ........... Verbose output for debugging
    --help .............. Show help for provided command

after run “ionic serve” in the ionic v.1 project

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

After run command

npm install --save-dev --save-exact @ionic/cli-plugin-ionic1@latest @ionic/cli-plugin-cordova@latest

if i launch again “ionic serve” command in ionic v.1 project directory, result doens’t change, i receive again

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

:cry:


#6

Oh, now I notice you already have the ionic-angular plugin in your project - and also Ionic Framework 3.1.1. Where did you run ionic info before? This indicates it was in a newly created project directory with the current Ionic version. Correct?

Can you run ionic info in the folder of you Ionic v1 project please?
(Same for the npm install command I posted before by the way)


#7

Hi Sujan12 and thank you again…

Before i have run “ionic info” in other directory, i have seen it now, sorry for the mistake

Run ionic info in my ionic v.1 directory project i receive

ionic info
[WARN] You are not in an Ionic project directory. Project context may be missing.

global packages:

    @ionic/cli-utils : 1.0.0
    Ionic CLI        : 3.0.0

System:

    Node       : v6.10.3
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.2 Build version 8E2002
    ios-deploy : not installed
    ios-sim    : not installed

i don’t understand beacuse system gives me this warnig

[WARN] You are not in an Ionic project directory. Project context may be missing.

i’m in ionic project directory!!

Even before i have launched this command in ionic v.1 project directory and it is the answer

> @ionic/cli-plugin-cordova@1.0.0 postinstall /Users/Project/car-app/node_modules/@ionic/cli-plugin-cordova
> node ./bin/postinstall

/Users/Project/car-app
├── @ionic/cli-plugin-cordova@1.0.0
└── @ionic/cli-plugin-ionic1@1.0.0

npm WARN Invalid name: "Car APP"
npm WARN radio No description
npm WARN radio No repository field.
npm WARN radio No README data
npm WARN radio No license field.

again launching command “ionic serve” in this directory i receive

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

#8

Yes but the v3 CLI obviously doesn’t recognize that.

Please run ionic info again in the v1 project directory to see if the plugins were successfully installed.


#9
ionic info
[WARN] You are not in an Ionic project directory. Project context may be missing.

global packages:

    @ionic/cli-utils : 1.0.0
    Ionic CLI        : 3.0.0

System:

    Node       : v6.10.3
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.2 Build version 8E2002
    ios-deploy : not installed
    ios-sim    : not installed

#10

Ok, then something more has to be broken.

What does package.json and config.xml look like in this folder?
What is the file structure in this folder? (tree should help to give an copyable overview)


#11

package.json and config.xml files are in folder

this is tree output of ionic v.1 directory project, i post pastebin url to simplicity

https://pastebin.com/5ReZH03e


#12

We need the content of package.json and config.xml - you can leave out your project details.
The tree is also only part of the complete output - run something like tree > file.txt to get it all into a file you can upload at pastebin.


#13

For package.json

https://pastebin.com/6Fb073hi

For config.xml

https://pastebin.com/LCxPR7Dg

Thank you Sujan12


#14

That is strange. Running npm install --save-dev --save-exact @ionic/cli-plugin-ionic1@latest @ionic/cli-plugin-cordova@latest should have added these here.

Have a look at the package.json from your newly created Ionic 3 project. Recreate what you find concerning these plugins in your package.json of the v1 project (and then change it from cli-plugin-ionic-angular to cli-plugin-ionic1!!) and then run npm install in the project directory of the v1 project.

Then ionic serve and ionic info again and give us the output.


#15

i haven’t understand all steps to follow…sorry


#16

No problem:

  1. Go to the newly created project (with Ionic 3.1.1) and open package.json
  2. There should be lines for the @ionic/cli-plugin ...s
  3. Copy these lines to package.json of your Ionic v1 project
  4. Change the ionic-angular to ionic1 (this defines which plugin it installs - here you need a different one than in the new project)
  5. Run npm install in your v1 project folder
  6. Then try ionic serve and ionic info again

#17

Hi, I had the same problem.

Try renaming the file ionic.project to ionic.config.json this works for me


#18

I have followed @GabberMan suggest and it has worked.

below new ionic info

ionic info

global packages:

    @ionic/cli-utils : 1.0.0
    Cordova CLI      : 7.0.0
    Ionic CLI        : 3.0.0

local packages:

    @ionic/cli-plugin-cordova : 1.0.0
    @ionic/cli-plugin-ionic1  : 1.0.0
    Ionic Framework           : ionic1 1.2.4

System:

    Node       : v6.10.3
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.2 Build version 8E2002
    ios-deploy : not installed
    ios-sim    : not installed

thank you for all @Sujan12, i don’t understand what it’s broken and because i need to modify ionic.project file in ionic.config.json, but it’s worked for me.

Thank you


#19

Hi I made a link with ln -s ionic.project ionic.config.json , so my teammates who are still using CLI 1 can keep using it.


#20

4 posts were split to a new topic: [ERROR] Sorry! ionic serve can only be run in an Ionic project directory


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