我正在使用 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']);
关于javascript - npm link gulp 之后任务 'default' 不在你的 gulpfile 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37546657/