繁体   English   中英

有没有办法告诉grunt node_modules在哪里?

[英]Is there a way to tell grunt where the node_modules is?

我为我的网站编写了很多单独的插件,并且使用grunt来管理它们的最终发行版。 我习惯于编写grunt.loadNpmTasks ,将特定的插件从node_modules目录导入我执行任务的Gruntfile

但是,为了做到这一点,我总是npm install <package> --save-dev使该插件在我正在编码的特定插件中可用。 但是由于它们是我现在要维护的数十个插件,所以我发现node_modules目录正变得越来越大,并且由于node_modules目录中充满了文件,因此备份变得越来越慢。

有没有办法集中化插件? 这样我就可以将所有的node_modules目录统一在一起吗? 并告诉grunt这个中央存储库在哪里加载特定插件?

编辑 :我试图为测试安装全局(-g)的grunt-contrib-less ,但仍然坚持说Local Npm module "grunt-contrib-less" not found. Is it installed? Local Npm module "grunt-contrib-less" not found. Is it installed?

我还没有测试。 但是值得尝试。 代替使用grunt.loadNpmTasks尝试使用load-grunt-tasks

您应该使用config选项,该选项允许您指定pacakge.json的路径。

require('load-grunt-tasks')(grunt, {config: '../package'});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM