Ionic CLI doesn't run gulp tasks on ionic serve

I have the same problem.

You have a solution?

As per the following, the 2.x.x will go directly into the gulpfile for tasks like watch and build.


(If you use Coffeescript gulpfile, there’s a further issue: https://github.com/driftyco/ionic-cli/issues/1004)

I have come across the same problem!

ionic serve works and loads my app in the browser, but the SCSS files aren’t compiled unless I manually run gulp sass and live reload doesn’t work anymore for my Ionic 1 app

Did you find a solution?

1 Like

Same problem here … The gulp startup tasks aren’t automatically started anymore …

Is there a solution to this yet?

Running gulp sass manually doesn’t seem to even work either

Hi, I think i found a solution for the issue.

Just add this to your gulpfile.js

gulp.task('serve:before', ['default']);

That line tells the new ionic cli 2@beta to run the old ionic cli 1.x ‘default’ task before serving (before running ionic serve)

Also you need to add a ionic.config.json file with this:

{
  "name": "base_project",
  "app_id": "",
  "v2": false,
  "typescript": false,
  "watch": {
    "sass": ["scss/**/*.scss"],
    "html": ["www/**/*.html"],
    "livereload": [
      "www/**/*.html",
      "www/**/*.js",
      "www/**/*.css"
    ]
  }
}

Hope that helps

14 Likes

I had the same issue, @agustinhaller solution solved it, now gulp task sass is running smoothly, Thanks!

1 Like

Oh. Thank you so much!

‘watch’ can be added to watch files also.

gulp.task('serve:before', ['default','watch']);

5 Likes

In my case, the following resolves it: sudo ionic hooks add

Check that you have the latest gulp-sass version in package.json; it’s a dependency of node-sass + required by Ionic, e.g.

"dependencies": {
    "gulp-sass": "^2.3.2"
  },

Uninstall gulp-sass

$ npm uninstall --save-dev gulp-sass

Reinstall gulp-sass

$ npm install --save-dev gulp-sass@2

There are a large number of issues pertaining to node-sass installation.
You may have to rebuild node-sass: $ npm rebuild node-sass

2 Likes

I am having the same issue.

  1. ionic setup sass
  2. ionic serve
  3. dosnt work…

I have to run gulp sass watch then run ionic serve and it works…

help:

$ ionic serve

There is an error in your gulpfile:
Error: /home/project/web/nodeJS/proyecto/app1/node_modules/node-sass/vendor/linux-x64-48/binding.node: failed to map segment from shared object: Operation not permitted
at Error (native)
at Object.Module._extensions…node (module.js:583:18)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object. (/home/project/web/nodeJS/proyecto/app1/node_modules/node-sass/lib/index.js:24:15)
at Module._compile (module.js:556:32)
at Object.Module._extensions…js (module.js:565:10)

It worked for me :ok_hand:

1 Like

worked! Thank you so much!

1 Like

It works… but not entirely. It does not work if you want to have livereload. Can we add that as well?

The solution discussed in this post should work with livereload also. (It’s working for me).

Can you please attach more information about the error you are getting?

Couldn’t figure out why, but it wasn’t working for me until I removed the “scripts” tag from package.json

Yeah, same thing here, that’s weird

Same thing here. Had to remove “scripts” tag from package.json.

I tried this and it’s not working for me… but I see it works for most… so thinking I’m doing something wrong. I updated my gulp file.js with your edit… and I created the ionic.config.json file. Am I suppose to reference/load the ionic.config.json file from another file, or does Ionic just pick the file up by it being loaded at root of project?