gulp-ng-annoate错误,由于解析错误而无法处理源 [英] error with gulp-ng-annoate, couldn't process source due to parse error

查看:85
本文介绍了gulp-ng-annoate错误,由于解析错误而无法处理源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在解决由gulp-ng-annoate生成的错误.

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

错误消息是

错误:app.js:错误:由于解析错误而无法处理源代码

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

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

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

gulpfile.js

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

和我要合并的文件/ngAnnotate

and files that I am trying to concat/ngAnnotate

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

推荐答案

错误的是,您放置了.而不是来分隔对象.

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

此外,请不要忘记; 结束行.

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

这篇关于gulp-ng-annoate错误,由于解析错误而无法处理源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆