1

I am getting trouble with error that is generated with gulp-ng-annoate.

Error message is

Error: app.js: error: couldn't process source due to parse error

I've found the other thread which seems to have same problem with me but that answer does not work for me. the other thread

Here is my gulp file and the files that I am trying to execute the tasks.

gulpfile.js

var gulp = require('gulp')
var concat = require('gulp-concat')
//var uglify = require('gulp-uglify')
var ngAnnotate = require('gulp-ng-annotate')

gulp.task('js', function(){
    gulp.src(['ng/module.js', 'ng/**/*.js'])
        .pipe(concat('app.js'))
        .pipe(ngAnnotate())
        //.pipe(uglify())
        .pipe(gulp.dest('assets'))
})

and files that I am trying to concat/ngAnnotate

module.js

angular.module('app', [])

posts.ctrl.js

angular.module('app')
.controller('PostCtrl', function($scope, PostsSvc){
    $scope.addPost = function(){
        if ($scope.postBody){
            PostsSvc.create({
                username: 'dickeyxxx',
                body: $scope.postBody
            }).success(function(post){
                $scope.posts.unshift(post)
                $scope.postBody = null
            })
        }
    }

    PostsSvc.fetch().success(function(posts){
        $scope.posts = posts
    })
})

posts.svc.js

angular.module('app')
.service('PostsSvc', ['$http', function ($http){
    this.fetch = function(){
        return $http.get('/api/posts')
    }
    this.create = function(post){
        return $http.post('/api/posts', post)
    }
}])

What could have gone wrong..?

Community
  • 1
  • 1
fkkcloud
  • 167
  • 4
  • 11

1 Answers1

2

What is wrong is that you put a . instead a , to separate object.

Also, don't forget the ; to end your line.

romuleald
  • 1,406
  • 16
  • 31
  • I am not sure which file's which line you are referring to for "put a . instead a , to separate object"? And I would assume that JS would allow not putting ; to end of line unless it is required? – fkkcloud Apr 23 '15 at 17:49
  • the problem is here : `PostsSvc.create({ username: 'dickeyxxx'. body: $scope.postBody})`. Adding `; `is the cleanest way to write JS, is you came to compress your code in 1 line, you will have some problems by omitting `;` – romuleald Apr 23 '15 at 19:08