簡體   English   中英

當我設置為默認值時,gulp 默認任務不起作用

[英]gulp default task isn't working when I set to default

我正在關注這個視頻,gulp 的代碼正在視頻中運行,但我遇到了問題:

當我運行gulp並將gulp設置為默認值時,但這是日志:

npm WARN npm npm does not support Node.js v10.15.2
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! missing script: default

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/me/.npm/_logs/2019-12-29T00_42_33_080Z-debug.log
me@vlife:gulf$ npm run gulp
npm WARN npm npm does not support Node.js v10.15.2
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/

> gulp-project@1.0.0 gulp /home/me/codedir/gulf
> gulp default

assert.js:350
    throw err;
    ^

AssertionError [ERR_ASSERTION]: Task function must be specified
    at Gulp.set [as _setTask] (/home/me/codedir/gulf/node_modules/undertaker/lib/set-task.js:10:3)
    at Gulp.task (/home/me/codedir/gulf/node_modules/undertaker/lib/task.js:13:8)
    at Object.<anonymous> (/home/me/codedir/gulf/gulpfile.js:23: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)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gulp-project@1.0.0 gulp: `gulp default`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the gulp-project@1.0.0 gulp script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/me/.npm/_logs/2019-12-29T00_42_44_118Z-debug.log

包.json:

{
  "name": "gulp-project",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "gulp": "gulp default"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "gulp": "^4.0.2",
    "gulp-cli": "^2.2.0",
    "gulp-sass": "^4.0.2",
    "node-sass": "^4.13.0"
  },
  "dependencies": {
    "gulp-uglifycss": "^1.1.0"
  }
}

代碼:

let gulp = require('gulp');
let sass = require('gulp-sass');
let uglifycss  = require('gulp-uglifycss');


// sass.compiler = require('node-sass');


gulp.task('sass', () => {
    return gulp.src('./scss/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./css'));
});

gulp.task('css', function () {
    gulp.src('./css/*.css')
      .pipe(uglifycss({
        "uglyComments": true
    }))
    .pipe(gulp.dest('./dist/'));
});

gulp.task('run', ['sass', 'css']);

gulp.task('watch', () => {
    gulp.watch('./scss/*.scss', ['sass']);
    gulp.watch('./css/*.css', ['css'])
});


gulp.task('default', ['run', 'watch']);

我也接口這個問題,甚至它已經修復

gulp.task('default', ['run', 'watch']);

gulp.parallel()

gulp.task('default', gulp.parallel('run', 'watch') );

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM