任务'--ship'不在您的gulpfile中

时间:2019-03-29 09:57:02

标签: node.js npm sharepoint gulp spfx

运行gulp bundle –ship时出现“任务'--ship'不在您的gulpfile中”错误。

enter image description here

我的gulpfile.js

use strict;

const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);

build.initialize(gulp);

有人可以帮助我解决此错误吗?

4 个答案:

答案 0 :(得分:0)

首先尝试使用以下命令刷新gulp安装:

npm install gulp --save

npm install --save

确保您的吞咽不只是被打破了。 然后您应该可以运行

gulp clean
gulp build
gulp bundle --ship
gulp package-solution --ship

看看它现在是否正常工作。

答案 1 :(得分:0)

命令gulp package-solution与package,-和solution之间的空格一起使用时,将产生错误。只需尝试以下命令,不要使用任何空格:

gulp打包解决方案

答案 2 :(得分:0)

如果在全局gulp上安装了npm npm i -g gulp软件包,则应使用下一个捆绑软件命令:gulp bundle --ship而不是gulp bundle -ship

您可以使用npm list -g --depth=0命令检查gulp全局安装。

答案 3 :(得分:-1)

您的gulp文件看起来不正确,没有任何任务。典型的gulp任务如下所示,任务名称为“ watch”,然后执行操作。

gulp.task('watch',function() {
  gulp.watch('src/*.scss',['sass']);
});

有关一些基本任务食谱,请参见this link