Grunt serve not working and change ionic serve to app folder


#1

Hi guys,

This forum is very helpful for a new ionic developer like me.

I am facing some issues while running my app. Below are the details about app and the questions which I have.

  1. I have setup my ionic app using yeomen - npm install -g generator-ionic. Able to build the android app using grunt build:android. Everything looks good in emulator.
  2. I am able to run using ionic serve (using browser) which fetches files from /www folder.

[Question]

  1. grunt serve is not working. It does not show any error but it is not running in browser. I have installed grunt and serve. What should I do for browser view?
  2. I want to change ionic serve to run the code from /app folder.

Thanks in advance.


#2

If you’re using the yeoman generator, it’s better to stick with the grunt serve, IMHO, there is some other important tasks that grunt serve will run for you with this generator.

Can you post the log of your grunt serve?

Did you run

npm install

and

bower install

just to make sure all the packages are downloaded?


#3

Did you check the gruntfile.js? Are you able to find the task serve in that file? If so, as @matheusbaumgart said try to install npm modules and bower components and then check it.


#4

Thanks for the response. Yes I have done all the installs. Below is the log of grunt serve(Sorry, forum does not have an option to upload log files). It says as build is successful. But when I hit the link it is not showing me anything.

E:\gitrepo\ionicapp>grunt serve
Running “serve” task

Running “wiredep:app” (wiredep) task

Running “clean:dist” (clean) task

9 paths cleaned.

Running “clean:server” (clean) task

0 paths cleaned.

Running “ngconstant:development” (ngconstant) task
Creating module config at app/scripts/configuration.js…OK

Running “wiredep:app” (wiredep) task

Running “concurrent:server” (concurrent) task

Running “copy:vendor” (copy) task

Done, without errors.

Execution Time (2015-07-30 10:04:36 UTC)
copy:vendor 15ms █████████████████████████████████████████████████ 100%
Total 15ms

Running “copy:styles” (copy) task
Copied 2 files

Done, without errors.

Execution Time (2015-07-30 10:04:36 UTC)
loading tasks 15ms ███████ 14%
copy:styles 94ms █████████████████████████████████████████ 86%
Total 109ms

Running “copy:fonts” (copy) task
Copied 4 files

Done, without errors.

Execution Time (2015-07-30 10:04:36 UTC)
copy:fonts 94ms ██████████████████████████████████████████████████ 100%
Total 94ms

Running “autoprefixer:dist” (autoprefixer) task
Autoprefixer’s process() method is deprecated and will removed in next major re
ease. Use postcss([autoprefixer]).process() instead
File .temp/styles/social-icons.css created.
Autoprefixer’s process() method is deprecated and will removed in next major re
ease. Use postcss([autoprefixer]).process() instead
File .temp/styles/style.css created.

Running “newer:copy:app” (newer) task

Running “copy:app” (copy) task
Created 90 directories, copied 360 files

Running “newer-postrun:copy:app:1:E:\gitrepo\ionicapp\node_modules\grunt-ne
er.cache” (newer-postrun) task

Running “newer:copy:tmp” (newer) task

Running “copy:tmp” (copy) task
Copied 2 files

Running “newer-postrun:copy:tmp:2:E:\gitrepo\ionicapp\node_modules\grunt-ne
er.cache” (newer-postrun) task

Running “concurrent:ionic” (concurrent) task
Running “ionic:serve” (ionic) task
Running “watch” task
Waiting…
Running live reload server: http://192.168.1.6:35729
Watching : [ ‘www//*’, '!www/lib//*’ ]
Running dev server: http://192.168.1.6:8100
Ionic server commands, enter:
restart or r to restart the client app from the root
goto or g and a url to have the app navigate to the given url
consolelogs or c to enable/disable console log output
serverlogs or s to enable/disable server log output
quit or q to shutdown the server and exit

ionic $
Done, without errors.

Execution Time (2015-07-30 10:04:43 UTC)
ionic:serve 6.9s █████████████████████████████████████████████████ 100%
Total 6.9s

@rajeshwarpatlolla: Yes. I am able to find serve in gruntfile.js.

grunt.registerTask(‘serve’, function (target) {
if (target === ‘compress’) {
return grunt.task.run([‘compress’, ‘ionic:serve’]);
}


#5

I am having the same exact issue.

One thing that got it to actually work for me was running

Grunt serve:compress

Problem is live-reload doesn’t work since everything gets compressed and uglified.

Still investigating for a proper solution.

Here is the full serve task.

grunt.registerTask('serve', function (target) {
    if (target === 'compress') {
      return grunt.task.run(['compress', 'ionic:serve']);
    }

    grunt.config('concurrent.ionic.tasks', ['ionic:serve', 'watch']);
    grunt.task.run(['wiredep', 'init', 'concurrent:ionic']);
  });

@Shyambv
EDIT: Fixed via instructions at here

sudo npm uninstall grunt-concurrent
sudo npm install grunt-concurrent@1.0.0