我有以下Gulp
任务:
var gulp = require('gulp');
var browserify = require('browserify');
var reactify = require('reactify');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');
var buffer = require('vinyl-buffer');
var derequire = require('gulp-derequire');
gulp.task('build-scripts', function () {
var b = browserify();
b.transform(reactify);
b.add('./Scripts/app/app.js');
return b.bundle()
.pipe(source('./Scripts/build/bundle.js'))
.pipe(derequire())
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('.'))
});
gulp.task('default', ['build-scripts']);
我通过 VS2013 中的任务运行资源管理器运行它。当我通过安装所有依赖npm cli
项并运行任务时,一切都按预期工作。添加后,package.json
我收到以下错误:
\ReactAccordion\gulpfile.js" build-scripts
[15:56:24] Using gulpfile ~\Documents\Visual Studio 2013\Projects\ReactAccordion\ReactAccordion\gulpfile.js
[15:56:24] Starting 'build-scripts'...
events.js:85
throw er; // Unhandled 'error' event
^
Error: SyntaxError: Unexpected token while parsing json file ReactAccordion\ReactAccordion\package.json
at ReactAccordion\node_modules\browserify\node_modules\module-deps\index.js:477:30
at fs.js:334:14
at FSReqWrap.oncomplete (fs.js:95:15)
Process terminated with code 1.
如果在恢复包后我package.json
从解决方案中删除了文件,则任务再次正常完成。我尝试搜索,但找不到报告的类似问题。通过查看 JS 文件,一切看起来都很好。
这是我的package.json
文件:
{
"name": "ReactAccordion",
"version": "1.0.0",
"private": true,
"dependencies": {
"react": "0.13.3"
},
"devDependencies": {
"gulp": "3.9.0",
"browserify": "~10.2.4",
"reactify": "1.1.1",
"vinyl-source-stream": "1.1.0",
"gulp-uglify": "1.2.0",
"vinyl-buffer": "1.0.0",
"gulp-derequire": "2.1.0"
}
}