簡體   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