Gulpfile.js加载失败

时间:2018-12-19 22:40:34

标签: javascript node.js npm gulp durandal

Visual Studio任务运行程序无法加载gulp文件。我现在使用 VS2017 v15.9.4 ,但是,该项目是几年前开发的。

- (BOOL)setupTexturesForFrame:(nonnull RTCVideoFrame *)frame {
  RTC_DCHECK([frame.buffer isKindOfClass:[RTCCVPixelBuffer class]]);
  if (![super setupTexturesForFrame:frame]) {
    return NO;
  }
  CVPixelBufferRef pixelBuffer = ((RTCCVPixelBuffer *)frame.buffer).pixelBuffer;
  id<MTLTexture> lumaTexture = nil;
  id<MTLTexture> chromaTexture = nil;
  CVMetalTextureRef outTexture = nullptr;
  // Luma (y) texture.
  int lumaWidth = CVPixelBufferGetWidthOfPlane(pixelBuffer, 0);
  int lumaHeight = CVPixelBufferGetHeightOfPlane(pixelBuffer, 0);
  int indexPlane = 0;
  CVReturn result = CVMetalTextureCacheCreateTextureFromImage(
      kCFAllocatorDefault, _textureCache, pixelBuffer, nil, MTLPixelFormatR8Unorm, lumaWidth,
      lumaHeight, indexPlane, &outTexture);
  if (result == kCVReturnSuccess) {
    lumaTexture = CVMetalTextureGetTexture(outTexture);
  }
  // Same as CFRelease except it can be passed NULL without crashing.
  CVBufferRelease(outTexture);
  outTexture = nullptr;
  // Chroma (CrCb) texture.
  indexPlane = 1;
  result = CVMetalTextureCacheCreateTextureFromImage(
      kCFAllocatorDefault, _textureCache, pixelBuffer, nil, MTLPixelFormatRG8Unorm, lumaWidth / 2,
      lumaHeight / 2, indexPlane, &outTexture);
  if (result == kCVReturnSuccess) {
    chromaTexture = CVMetalTextureGetTexture(outTexture);
  }
  CVBufferRelease(outTexture);
  if (lumaTexture != nil && chromaTexture != nil) {
    _yTexture = lumaTexture;
    _CrCbTexture = chromaTexture;
    return YES;
  }
  return NO;
}

我将项目的本地地址替换为“ ...”

Failed to run "...\Gulpfile.js"...
cmd.exe /c gulp --tasks-simple
assert.js:350
    throw err;
    ^
AssertionError [ERR_ASSERTION]: Task function must be specified
    at Gulp.set [as _setTask] (...\node_modules\undertaker\lib\set-task.js:10:3)
    at Gulp.task (...\node_modules\undertaker\lib\task.js:13:8)
    at Object.<anonymous> (...\gulpfile.js:34:6)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)

package.json 文件的内容:

npm -v --> 6.4.1

node -v --> 10.14.2

gulp -v --> CLI version 2.0.1
            Local version 4.0.0

gulpfile.js 的内容:

{
  "version": "1.0.0",
  "name": "tratic",
  "private": true,
  "devDependencies": {
    "gulp": "github:gulpjs/gulp#4.0",
    "gulp-clean-css": "3.5.0",
    "gulp-concat": "2.6.1",
    "gulp-durandal": "1.1.7",
    "gulp-install": "^1.1.0",
    "gulp-uglify": "3.0.0",
    "gulp-util": "3.0.8",
    "rimraf": "2.6.1"
  },
  "dependencies": {
    "assert": "^1.4.1",
    "assert-js": "^0.20.0",
    "natives": "^1.1.5"
  },
  "scripts": {
    "gulp": "./node_modules/gulp/bin/gulp.js"
  }
}

我用google搜索,现有解决方案无法解决问题。有一些相关问题,但对我不起作用。

我该如何解决问题?

3 个答案:

答案 0 :(得分:4)

我尝试了您的设置,确实引发了像您一样的错误。 我去了gulp docs并尝试了他们的gulpfile版本,它没有任何问题。因此,我重写了您的gulpfile以匹配他们的示例,并且效果很好。 这是代码:


    var gulp = require('gulp'),
        durandal = require('gulp-durandal'),
        rimraf = require('rimraf');

    var paths = {
        app: "./App/**/*.js",
        js: "./Scripts/**/*.js",
        css: "./Content/**/*.css",
        concatJsDest: "./Scripts/vendor-scripts.min.js",
        concatCssDest: "./Content/vendor-css.min.css"
    };

    function clean (cb) {
      rimraf('app/main-built.js', cb);
    }

    gulp.task('clean', clean);

    function runDurandal () {
      return durandal({
          baseDir: 'app',
          main: 'main.js',
          output: 'main-built.js',
          almond: true,
          minify: true,
          rjsConfigAdapter: function (rjsConfig) {
              rjsConfig.deps = ['text'];
              return rjsConfig;
          }
      })
      .pipe(gulp.dest('app'));
    }

    var build = gulp.series(clean, runDurandal);

    gulp.task('default', build);

基本上,我已经将用作任务的函数移到了变量上,并使用系列来运行durandal。

然后我尝试了npx gulp --tasks-simple 并有适当的输出

clean
default

顺便说一句,看看npx,这样就不必全局安装gulp。

希望有帮助!

答案 1 :(得分:3)

gulp4不再允许使用此语法:

thislist = [x for x in ("apple", "banana", "cherry")]

使用:

thislist = []  # or thislist = list()
for x in ("apple", "banana", "cherry"):
    thislist.append(x)

类似地更改为:

gulp.task('default', ['durandal']);

此外,使用pump可能会比没有它带来更好的错误报告。

答案 2 :(得分:0)

尝试使用此替代方法:https://github.com/ampproject/docs/issues/793 将gulp降级到此版本3.9.1。