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