[英]How to use grunt-html installed globally?
I would like to use grunt-html
task to check my HTML files. 我想使用
grunt-html
任务来检查我的HTML文件。
I install the task locally with npm install grunt-html
and use it in grunt.js
as follows: 我使用
npm install grunt-html
在本地安装任务,并在grunt.js
使用它,如下所示:
module.exports = function (grunt) { grunt.loadNpmTasks('grunt-html'); grunt.initConfig({ htmllint:{ all:['*.html'] }, }); };
Now I would like to install the grunt-html
task globally . 现在我想在全局安装
grunt-html
任务。
Unfortunately after removing the local grunt-html
node module and installing it globally grunt
fails to load the task. 不幸的是,在删除本地
grunt-html
节点模块并将其全局安装后, grunt
无法加载任务。 While running grunt htmllint
I get: 在运行
grunt htmllint
我得到:
>> Local Npm module "grunt-html" not found. Is it installed?
If I remove grunt.loadNpmTasks('grunt-html');
如果我删除
grunt.loadNpmTasks('grunt-html');
from the grunt.js
file I get: 从
grunt.js
文件我得到:
Task "htmllint" not found. Use --force to continue.
So my question is how to use grunt-html
installed globally ? 所以我的问题是如何使用全局安装的
grunt-html
?
gruntjs doesn't currently support loading globally-installed grunt modules from loadNpmTasks
, per the documentation of grunt.loadNpmTasks
: 根据
loadNpmTasks
的文档, grunt.loadNpmTasks
目前不支持从loadNpmTasks
加载全局安装的grunt模块:
This plugin must be installed locally via npm, and must be relative to the grunt.js gruntfile.
此插件必须通过npm本地安装,并且必须相对于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. 当然,如果你真的坚持全局安装它,那么hack就是从你的本地
node_modules
目录到你的全局node_modules/grunt-html
目录创建一个符号链接( ln -s
)。
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). 如果您正在进行模块开发,另一种方法是使用
npm link
受欢迎的npm link
命令,该命令允许您在本地安装系统中其他位置的模块(有关使用信息,请参阅npm help link
)。
Both of these approaches, though, don't allow you to truly install the grunt-html
package globally. 但是,这两种方法都不允许您在全局范围内真正安装
grunt-html
软件包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.