[英]How to use grunt-html installed globally?
我想使用grunt-html
任務來檢查我的HTML文件。
我使用npm install grunt-html
在本地安裝任務,並在grunt.js
使用它,如下所示:
module.exports = function (grunt) { grunt.loadNpmTasks('grunt-html'); grunt.initConfig({ htmllint:{ all:['*.html'] }, }); };
現在我想在全局安裝grunt-html
任務。
不幸的是,在刪除本地grunt-html
節點模塊並將其全局安裝后, grunt
無法加載任務。 在運行grunt htmllint
我得到:
>> Local Npm module "grunt-html" not found. Is it installed?
如果我刪除grunt.loadNpmTasks('grunt-html');
從grunt.js
文件我得到:
Task "htmllint" not found. Use --force to continue.
所以我的問題是如何使用全局安裝的grunt-html
?
根據loadNpmTasks
的文檔, grunt.loadNpmTasks
目前不支持從loadNpmTasks
加載全局安裝的grunt模塊:
此插件必須通過npm本地安裝,並且必須相對於grunt.js gruntfile。
當然,如果你真的堅持全局安裝它,那么hack就是從你的本地node_modules
目錄到你的全局node_modules/grunt-html
目錄創建一個符號鏈接( ln -s
)。
如果您正在進行模塊開發,另一種方法是使用npm link
受歡迎的npm link
命令,該命令允許您在本地安裝系統中其他位置的模塊(有關使用信息,請參閱npm help link
)。
但是,這兩種方法都不允許您在全局范圍內真正安裝grunt-html
軟件包。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.