我有一个通过 npm 安装的 grunt 任务taskA
(不是实际名称)
taskA 有一个依赖项:grunt-contrib-stylus,它在 taskA 的 package.json 中指定并安装。由于某种原因,当从主 Gruntfile.js 运行grunt default时,它会给出错误。
Warning: Task "stylus" not found. Use --force to continue.
解决方法是在主项目中要求 grunt-contrib-stylus。我想避免这种情况。我的任务没有在其 node_modules/ 中使用 grunt-contrib-stylus 的原因是什么?
任务A
module.exports = function(grunt) {
'use strict';
grunt.loadNpmTasks('grunt-contrib-stylus');
...
主要的 Gruntfile.js
...
grunt.loadNpmTasks('taskA');
...