当我运行gulp时,我得到 "AssertionError [ERR_ASSERTION]: 任务函数必须被指定",当我运行gulp

问题描述 投票:0回答:1

对于一些背景,我正试图为微软团队开发应用程序。所以我决定按照 'Hello World'项目 但我在生成应用程序包(zip文件)时遇到了一个问题。我使用的是Win10

下面是我的node和gulp的版本。

$ gulp -v
CLI version: 2.2.0
Local version: 4.0.0

$ node -v
v12.14.1

我的错误 :(

$ gulp
assert.js:374
    throw err;
    ^

AssertionError [ERR_ASSERTION]: Task function must be specified
    at Gulp.set [as _setTask] (C:\Users\Comp\source\entitled\msteams-samples-hello-world-nodejs\node_modules\undertaker\lib\set-task.js:10:3)
    at Gulp.task (C:\Users\Comp\source\entitled\msteams-samples-hello-world-nodejs\node_modules\undertaker\lib\task.js:13:8)
    at Object.<anonymous> (C:\Users\Comp\source\entitled\msteams-samples-hello-world-nodejs\gulpfile.js:17:6)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at execute (C:\Users\Comp\AppData\Roaming\npm\node_modules\gulp-cli\lib\versioned\^4.0.0\index.js:36:18) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

包.json

{
  "name": "msteams-nodejs-hello-world",
  "version": "1.0.0",
  "description": "Microsoft Teams Node.js Hello World App. Start here to build your first app on the Teams platform.",
  "scripts": {
    "start": "node src/app.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/OfficeDev/msteams-samples-hello-world-nodejs.git"
  },
  "author": "Microsoft Corp.",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/OfficeDev/msteams-samples-hello-world-nodejs/issues"
  },
  "homepage": "https://docs.microsoft.com/en-us/microsoftteams/platform/get-started/get-started-nodejs",
  "dependencies": {
    "botbuilder": "^3.11.0",
    "botbuilder-teams": "^0.1.6",
    "config": "^1.28.1",
    "express": "^4.16.2",
    "faker": "^4.1.0",
    "natives": "^1.1.6",
    "node": "^10.13.0",
    "pug": "^2.0.4"
  },
  "devDependencies": {
    "del": "^3.0.0",
    "gulp": "^4.0.0",
    "gulp-install": "^1.1.0",
    "gulp-zip": "^4.0.0"
  }
}

gulpfile.js

var gulp = require('gulp');
var zip = require('gulp-zip');
var del = require('del');

gulp.task('clean', function() {
    return del([
        'manifest/**/*'
    ])
});

gulp.task('generate-manifest', function() {
    gulp.src(['src/static/images/contoso*', 'src/manifest.json'])
        .pipe(zip('helloworldapp.zip'))
        .pipe(gulp.dest('manifest'));
});

gulp.task('default', ['clean', 'generate-manifest'], function() {
    console.log('Build completed. Output in manifest folder');
});

我阅读了一些其他文章,其中我不得不降级node和gulp,但我没有运气。

node.js gulp microsoft-teams
1个回答
0
投票
gulp.task('generate-manifest', function() {
    return gulp.src(['src/static/images/contoso*', 'src/manifest.json'])  // change here
        .pipe(zip('helloworldapp.zip'))
        .pipe(gulp.dest('manifest'));
});

gulp.task('default', gulp.series('clean', 'generate-manifest', function() {  // change here
    console.log('Build completed. Output in manifest folder');
}));

不需要降级gulp或node。 你只需要用gulp4语法代替gulp3。

© www.soinside.com 2019 - 2024. All rights reserved.