Ionic serve not working with ionic2 - ionic-framework

I have started a clean project with ionic2 based on tabs template, by following the next steps:
$ ionic start <myapp> --v2
$ cd <myapp>
$ ionic serve
Then the output from ionic serve is just:
> ionic-hello-world# ionic:serve /home/luan/<myapp>
> ionic-app-scripts serve "--v2" "--address" "0.0.0.0" "--port" "8100" "--livereload-port" "35729"
If I try to open localhost:8100 there's no response.
The files and code of the project are just the same as one using tabs template, but it's just don't wonking.
Could someone help?
UPDATE:
My ionic info
My system information:
Cordova CLI: 6.5.0
Ionic Framework Version: 2.3.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.2.2
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.4
Node Version: v6.10.0
Xcode version: Not installed

Have you tried using
npm run ionic:serve

I have found the answer. It turns out, the 1.2.2 version of Ionic App Scripts (app-scripts) version was the problem. Just downgraded to 1.1.4 and works fine. The actual workaround:
in package.json, change
"#ionic/app-scripts": "1.2.2"
to
"#ionic/app-scripts": "1.1.4"
then run npm install again. It should show something like this:
[...]
- sentence-case#2.1.1 node_modules/sentence-case
- change-case#3.0.1 node_modules/change-case
ionic-hello-world# /home/luan/Projetos/prestacontas
└── #ionic/app-scripts#1.1.4 ## The problem was here
Make shure that #ionic/app-scripts is now 1.1.4, and not 1.2.2.
And that's it.

Here is a solution for you,,, :)
Most probably this can be an issue of updating. Because I opened two of my ionic projects. one is from late 2017. For that project live reload is working without an issue. The problem with my new project. I checked the "ionic info" and found that both are same other than the ionic framework version. my older one is v 3.7.1. unfortunately, that version not installing now. don't know exactly what the problem is.
However, I found a solution,
instead of "Ionic serve" command run the following command for the first time. then you will not need to run "ionic serve" each time.
npm run ionic:serve

I had the same error when I updated Ionic. I worked around it by using:
ionic serve --address localhost
The above solution to use "#ionic/app-script": "1.2.2" works to have it use localhost instead of 0.0.0.0. However it created other errors that were easily fixed by following the addition warnings.
"devDependencies": {
"#ionic/app-scripts": "1.2.2",
The one new error I still couldn't pinpoint yet is:
Error Close Runtime Error timeStamp.getDate is not a function Stack
TypeError: timeStamp.getDate is not a function
at HomePage.timeSince (http://localhost:8100/build/main.js:70141:33)
at SafeSubscriber._next (http://localhost:8100/build/main.js:70088:42)
at SafeSubscriber.__tryOrUnsub (http://localhost:8100/build/main.js:69844:16)
at SafeSubscriber.next (http://localhost:8100/build/main.js:69793:22)
at Subscriber._next (http://localhost:8100/build/main.js:69746:26)
at Subscriber.next (http://localhost:8100/build/main.js:69710:18)
at XMLHttpRequest.onLoad (http://localhost:8100/build/main.js:44518:38)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:14051)
at Object.onInvokeTask (http://localhost:8100/build/main.js:27788:37)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:13987) Ionic Framework: 2.0.0-rc.2 Ionic Native: 2.2.3 Ionic App Scripts:
1.2.2 Angular Core: 2.1.1 Angular Compiler CLI: 2.1.1 Node: 6.9.1 OS Platform: Windows 10 Navigator Platform: Win32 User Agent: Mozilla/5.0
(Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/56.0.2924.87 Safari/537.36
The app does run but that window popped up on Chrome and I had to close it before I could see the output of the app.

Related

Ionic v4: "Ionic cordova run -l" won't start my app

Additional notes for upcoming viewers
This seems to be a common problem on macOS: https://github.com/ios-control/ios-sim/issues/253
Temporary solution below this question.
I've worked on a fresh ionic project a few days ago and I had no problems back then whatsoever.
Today I tried to start the development server: ionic cordova run -l but then I got this error message:
No target specified for emulator. Deploying to undefined simulator
Device type "com.apple.CoreSimulator.SimDeviceType.undefined" could not be found.
An error occurred while running subprocess cordova.
Logging currently available devices(ionic cordova run --list) gives me this output:
Available ios devices:
Available ios virtual devices:
It is empty. None devices are available. Not for ios and neither for android.
Ionic version: 4.12.0
Cordova version: 9.0.0
Nodejs version: 11.5.0
I would appreciate any help to make this work again.
Seems like you have upgraded the Mac OS, faced similar problem in past and updating and re-installing iOS-sim was not of much help.
For me following command worked without installing anything further
ionic cordova emulate ios --livereload --consolelogs --target="iPhone-6,com.apple.CoreSimulator.SimRuntime.iOS-12-2"
Also, you can try this one if above don't work
ionic cordova emulate ios --livereload --consolelogs --target="iPhone-6,com.apple.CoreSimulator.SimRuntime.iOS-12-2" --buildFlag="-UseModernBuildSystem=0"
Do the following:
cd platforms/ios/cordova && npm install ios-sim#latest
cd ../../../
cordova platform rm ios
cordova platform add ios#4.5.0
ionic cordova emulate ios --target --list
ionic cordova plugin rm cordova-plugin-console
That should do it.

How to keep both ionic 1, 3, version in my system

Initaially i was working with ionic 1.7.6 version with many apps. And by today some how i have changed to version 3.0.0. Now when i open my old projects under package.json i see the version as 3.0.0 instead of 1.7.6. And when i do sudo ionic build android it throws me some error to upgrade the version.
So now i have uninstall the ionic & cordova from my system.
Now i want to keep ionic 1 version 1.7.6 as well as ionic 3 version 3.0.0 how can i do it now.
so when ever i open the ionic 1 project i need to work on angularjs with ionic 1 version.
And when ever i open the project that i have created with version 3 i need to work with latest version of angular is with ionic 3..
please some one expalain me what should i need to do ??
Thank in advance !
I suspect you have installed ionic globally. If you want to run the local/project version of ionic you need to sudo ./node_modules/ionic/ionic ....
This will be the version of ionic as defined in the package.json of the project.
You can tuck this nicely away however using npm scripts (in your package.json):
e.g.
"scripts": {
"ionic": "sudo ./node_modules/ionic/ionic build "
}
Ten simply execute npm run ionic -- android

Ionic Live Reload not working

Live Reload has stopped working.
When I save code changes, the browser automatically refreshes, but code changes are not reflected. I need to stop my CLI and run ionic serve again in order to have any code changes reflected in the browser.
Your system information:
Cordova CLI: 6.4.0
Ionic Framework Version: 2.3.0
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 1.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: macOS Sierra
Node Version: v6.9.4
Xcode version: Xcode 8.2.1 Build version 8C1002
I think your problem is with your current project.So please create a new project like below.
ionic start myfirstapp blank --v2
After that see whether live reload is working or not.It should work now.
ionic serve
Note: If above one is working then you can copy/ paste your previous project's custom items where you have created to this project.Hope that solution will be much quicker than try to find a solution with the old project.That is my idea.
I did these to resolve this error on my ubuntu
Remove the npm_folder and package-lock.json files
Run npm install --save-dev
Restart your system

ionic serve --lab not showing different platform views

I have recently been trying to ionic labs view a try. From the docs, its as simple as the command ionic serve --lab . But this only shows the normal ionic serve view not android and iphone view . I do not see any errors.
$ ionic serve -l
> ionic-hello-world# ionic:serve /home/raj/ionic/bookemon
> ionic-app-scripts serve "--v2" "--lab" "--address" "0.0.0.0" "--port" "8100" "--livereload-port" "35729"
[12:10:35] ionic-app-scripts 1.0.0
[12:10:35] watch started ...
[12:10:35] build dev started ...
[12:10:35] clean started ...
[12:10:35] clean finished in 6 ms
[12:10:35] copy started ...
[12:10:35] transpile started ...
[12:10:39] transpile finished in 3.58 s
[12:10:39] webpack started ...
[12:10:39] copy finished in 3.74 s
[12:10:46] webpack finished in 6.89 s
[12:10:46] sass started ...
[12:10:47] sass finished in 719 ms
[12:10:47] build dev finished in 11.23 s
[12:10:47] watch ready in 11.31 s
[12:10:47] dev server running: http://localhost:8100/
This is my ionic info
Your system information:
Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.6
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.4
Node Version: v7.2.1
Xcode version: Not installed
Not sure whats going on here. I tried reinstalling ionic and npm_modules but its not working. Any help? Thanks in advance.
Are you sure that you are opening http://localhost:8101/ionic-lab and NOT just http://localhost:8101 ?
Run ionic serve --lab or ionic serve -l
Goto http://localhost:8101/ionic-lab
Note
localhost:8101 loads the normal view and
localhost:8101/ionic-lab loads the view with options to various platform
"scripts": {
"build": "ionic-app-scripts build",
"watch": "ionic-app-scripts watch",
"serve:before": "watch",
"emulate:before": "watch",
"deploy:before": "build",
"build:before": "build",
"run:before": "watch"
}
In package.json change scripts to above and run ionic serve -l
i think ionic serve -l doesn't work since ionic 2 using
ionic-app-scripts.
while, them using ionic view app, for live test.
check here https://play.google.com/store/apps/details?id=com.ionic.viewapp&hl=en

Ionic run / build not working

when execute "ionic run android " nothing happens !!!
No Errors, No Messages - what happens?
I had the same issue, dropping my version of Node to 4.2.1 fixed it.
See: Ionic run does nothing
I thing the steps below can help, at least you can get a better log, to solve your problem:
Make sure you added a platform to your project
$ ionic platform add android
Once you have a platform try to run using cordova
$ cd {YOUR_PROJECT_DIR}/platforms/android/cordova
$./run
i just got in same kind..!
so,just check setup with ionic info command
Your system information:
Cordova CLI: 5.4.1
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.0
Ionic Version: 1.1.0
Ionic CLI Version: 1.7.12
Ionic App Lib Version: 0.6.5
OS: Distributor ID: Ubuntu Description: Ubuntu 14.04.2 LTS
Node Version: v5.4.0
i just upgrade cordova version to 5.4.1
this setup,worked for me..!
fix is here (FOR WINDOWS ONLY)
I am facing the same problem of Build then i finally found out the solution.
SOLUTION
So You must have the Android Api 23 in order for this command to work.
Error of Daemon process will be solve after installing the Api 23 and extra build tools and run command
COMMAND : cordova build android --release
I am sure this fix would help you to solve the problem.
STEPS
1. First check the version of android through this COMMAND:
cordova platform help
2. Run the build command after installing the Api 23 and extra build tools.
3. If Even this not work then Try add the variable in the
Environment variables > System variables >
add _JAVA_OPTIONS and value = -Xmx512M
Then Run cordova build android --release
BUT FIRSTLY SET UP THE ENVIRONMENT VARIABLES
Environment Variable setup Image
android API 23
COPY FROM HERE
ENVIRONMENT VARIABLES:-
USER VARIABLES
PATH
C:\Ruby23\bin;C:\Users\kumar\AppData\Roaming\npm;C:\ANDROID_SDK\tools;%SystemRo
ot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;
SYSTEM VARIABLES
ADD NAME AND VALUE
2.1 _JAVA_OPTIONS -Xmx512M
2.2 ANDROID_HOME C:\ANDROID_SDK
2.3 PATH ->
C:\ProgramFiles\Java\jdk1.8.0_60\bin;C:\ProgramFiles\nodejs;C:\Gradle\gradle-4.0\bin;C:\ANDROID_SDK\tools;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;