[英]grunt Warning Task “watch” not found
Gruntfile.js: Gruntfile.js:
grunt.initConfig({
watch: {
compass: {
files: [
'app/styles/**/*.{scss,sass}'
],
tasks: 'compass reload'
},
.....
grunt.registerTask('dev', 'watch');
when i run 当我跑
grunt dev
i get the error 我收到了错误
Warning: Task "watch" not found. Use --force to continue.
I use grunt-cli v0.1.6 and grunt v0.4.0, grunt-contrib-watch is installed. 我使用grunt-cli v0.1.6和grunt v0.4.0,安装了grunt-contrib-watch。
You don't have to install the whole contrib-package. 您不必安装整个contrib-package。 There is a separate one for watch
有一个单独的手表
npm install grunt-contrib-watch --save-dev
and at the end: 最后:
grunt.loadNpmTasks('grunt-contrib-watch');
Well. 好。
npm install grunt-contrib --save-dev
and add this line before the last line of grunt.js: 并在grunt.js的最后一行之前添加此行:
grunt.loadNpmTasks('grunt-contrib');
Also, i had to have Ruby installed... 另外,我必须安装Ruby ...
实际上,如果没有安装插件,你就不会有错误launcinh grunt watch
,只是一个无法加载watch
任务的错误。
I know the question is old, but it was not properly answered yet since Serge stated 我知道这个问题已经过时了,但是自从Serge说出来之后,它还没有得到妥善回答
grunt-contrib-watch is installed.
安装了grunt-contrib-watch。
I would check if the whole Gruntfile is wrapped by 我会检查整个Gruntfile是否被包装
module.exports = function (grunt) {
};
When you close this function (by accident) prematurely you get the described error. 当您过早关闭此功能(意外)时,您会收到所描述的错误。
浏览器更新和npm更新对我有用。
when I ran grunt watch on terminal, encountered error and fixed: 当我在终端上运行grunt watch时遇到错误并修复:
Error 错误
grunt watch
Loading "Gruntfile.js" tasks...ERROR
FIX in Terminal 在终端修复
brew install npm
brew install node
then you Test node and npm worked 然后你测试节点和npm工作
node -v npm -v
Install Grunt 安装Grunt
npm install -g grunt-cli npm install grunt-contrib-watch --save-dev
Install Composer 安装Composer
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
then ran 然后跑了
grunt watch
It worked! 有效!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.