簡體   English   中英

如何使用全局安裝的grunt-html?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM