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

淺唱寂寞╮ 提交于 2021-02-08 07:48:22

问题


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..?


回答1:


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

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



来源:https://stackoverflow.com/questions/29816958/error-with-gulp-ng-annoate-couldnt-process-source-due-to-parse-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!