如何使用全局安装的grunt-html? [英] How to use grunt-html installed globally?
问题描述
我想用 grunt-html
任务来检查我的HTML文件。
我安装任务在 npm install grunt-html
并在 grunt.js
中使用 local ,如下所示:
module.exports =函数(grunt){
grunt.loadNpmTasks('grunt-html');
grunt.initConfig({
htmllint:{
all:['*。html']
},
});
};
现在我想安装 grunt-html
全局。
不幸的是,在删除本地 grunt-html
安装它全局 grunt
无法加载任务。运行 grunt htmllint
时得到:
>>找不到本地Npm模块grunt-html 。它是否已安装?
如果我从 grunt.js
文件:
找不到任务htmllint。使用--force继续。
所以我的问题是如何全局使用 grunt-html
已安装的 ?
gruntjs目前不支持从 loadNpmTasks $ c加载全局安装的grunt模块$ c>,每个
grunt.loadNpmTasks code>
:
这个插件必须通过npm本地安装,并且必须与grunt.js相关gruntfile。
当然,如果你真的坚持全局安装它,黑客应该创建一个符号链接( ln -s
)从您的本地 node_modules
目录添加到您的全局 node_modules / grunt-html
目录。
如果您正在进行模块开发,另一种方法是使用低估的 npm链接
命令,可让您本地安装系统中其他位置存在的模块(有关使用信息,请参阅 npm help link
)。
然而,这两种方法都不允许您真正安装全局的 grunt-html
包。
I would like to use grunt-html
task to check my HTML files.
I install the task locally with npm install grunt-html
and use it in grunt.js
as follows:
module.exports = function (grunt) { grunt.loadNpmTasks('grunt-html'); grunt.initConfig({ htmllint:{ all:['*.html'] }, }); };
Now I would like to install the grunt-html
task globally.
Unfortunately after removing the local grunt-html
node module and installing it globally grunt
fails to load the task. While running grunt htmllint
I get:
>> Local Npm module "grunt-html" not found. Is it installed?
If I remove grunt.loadNpmTasks('grunt-html');
from the grunt.js
file I get:
Task "htmllint" not found. Use --force to continue.
So my question is how to use grunt-html
installed globally?
gruntjs doesn't currently support loading globally-installed grunt modules from loadNpmTasks
, per the documentation of grunt.loadNpmTasks
:
This plugin must be installed locally via npm, and must be relative to the grunt.js gruntfile.
Of course, if you really insist on installing it globally, a hack would be to create a symlink (ln -s
) from your local node_modules
directory to your global node_modules/grunt-html
directory.
If you're doing module development, another alternative would be to use the under-appreciated npm link
command that lets you locally install a module that exists elsewhere on you system (see npm help link
for usage information).
Both of these approaches, though, don't allow you to truly install the grunt-html
package globally.
这篇关于如何使用全局安装的grunt-html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!