gulp-ng-annoate 出错,由于解析错误无法处理源

error with gulp-ng-annoate, couldn't process source due to parse error

我遇到了 gulp-ng-annoate 生成的错误问题。

错误信息是

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

我发现另一个线程似乎与我有同样的问题,但那个答案对我不起作用。

这是我的 gulp 文件和我正在尝试执行任务的文件。

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'))
})

和我正在尝试的文件 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)
    }
}])

可能出了什么问题..?

错误的是你用 . 而不是 , 来分隔对象。

此外,不要忘记用 ; 结束您的行。