javascript - npm link gulp 之后任务 'default' 不在你的 gulpfile 中

标签 javascript node.js gulp

我正在使用 gulp 并在 gulpfile.js 中定义了我的 gulp 任务 因为我不想每次使用时都安装 gulp

npm install gulp -g
npm link gulp 

(我要执行 gulp 的目录中的链接命令) 之后,命令“gulp”在我的工作目录中可用,但它输出:

Task 'default' is not in your gulpfile Blockquote

如果我把控制台日志放在我的gulpfile.js的开头,我可以看到他输出日志并且可以找到gulpfile.js

谁能告诉我我的问题出在哪里?

我找到了这篇文章,但它对我没有帮助 How to fix "Task is not in your gulpfile" error when using npm link?

非常感谢

最佳答案

有两个问题。

<强>1。 npm链接的滥用

npm 链接有什么作用?

it first creates a global link, and then links the global installation target into your project's node_modules folder.

https://docs.npmjs.com/cli/link

因此,如果您想全局安装软件包,请不要使用 npm link,因为它会创建一个指向您本地 node_modules 文件夹的全局链接。

<强>2。您的 gulpfile 中没有默认任务

如果您想使用不带参数的 gulp 命令(因此您需要默认行为),那么您应该指定此任务。 例如:

// The default task (called when you run `gulp` from cli)
gulp.task('default', ['watch', 'scripts', 'images']);

https://github.com/gulpjs/gulp#sample-gulpfilejs

关于javascript - npm link gulp 之后任务 'default' 不在你的 gulpfile 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37546657/

相关文章:

javascript - 使用 Gulp 检查文件中是否存在 token

javascript - 是否可以在 es6 中编写 gulpfile?

node.js - Chrome 远程接口(interface)的异步/等待问题

javascript - Mongoose 计算返回数组的数量?

javascript - 如何使用 js-quantities 转换为最佳前缀?

node.js - NPM 安装错误 (Laravel)

javascript - 创建 JSON 时如何使用变量

javascript - 重构循环内的循环以总结属性总数

javascript - mapbox LineString 跟随道路

javascript - 如何验证 vue.js 中的动态输入字段?