Ionic can't login Request: POST https://api.io

2019-02-08 01:02发布

问题:

When I try to run any Ionic CLI commands that require login I get a 404 error.

Here's the command line....

? Password: [hidden]
Request: POST https://api.ionic.io/login
Response: 404
Body: 
{ link: null,
  message: 'No user found by that email',
  type: 'NotFound' }

I am definitely entering the correct account details, to ensure this I even created several new accounts at https://dashboard.ionicjs.com/signup, ensured I had validated the email address but still the same error.

(I have just lost 8 hours to this problem so am posting Q&A here to help others.)

回答1:

This error is due to the fact that Ionic are transitioning to "Ionic Pro" and the CLI needs to use the correct API. The fact that it is attempting to post login requests to api.ionic.io/login shows it's trying to use the old legacy system. You configure which system it uses by setting the backend value in the config.

To Fix:

Firstly, make sure your Ionic CLI is bang up-to-date.

Check the version:

ionic cli -v

It should be 3.9.2 at time of writing. If not update it:

npm install -g ionic@latest 

Now you've got the latest CLI you need to tell it to use "pro" not legacy:

ionic config set backend pro -g

NOTE: When I did this on my machine it did not work at first and I still got the same "No user found" error. I actually had to switch the backend to "legacy" first (using that same command) and then back to "pro". I have no idea why this fixed it but it did.



回答2:

Assuming you have already installed git in windows...

1) Control Panel > System > Edit the system variables

2) System Properties > Advanced (Tab) > Environment Variables (Bottom of tab)

3) System Variables > New

Variable Name: ssh-keygen

Variable Value C:\Program Files\Git\git-cmd

Click ok

4) Close and restart you CMD/Shell Window

4) in the CMD window type ionic login