【问题标题】:Grunt serve Warning: Task "serve" not found. Use --force to continue.( revisited)Grunt serve 警告:找不到任务“服务”。使用 --force 继续。(重新访问)
【发布时间】:2016-08-08 08:46:28
【问题描述】:

我一直在尝试在我的 Win 10 64 位开发机器上测试 Web 应用生成器,所以我打开了一个 PS Shell 命令窗口并按照这些步骤操作

 // 1. Install core of yeoman
 npm install -g yo
 // Wait until yeoman installation is completed
 // 2. Install bower
npm install -g bower
// Wait until bower installation is completed
// 3. Install Grunt Client
 npm install -g grunt-cli
// Wait until grunt client installation is completed
// 4. Install the first generator
npm install -g generator-webapp

  *npm WARN deprecated graceful-fs@2.0.3: graceful-fs version 3 and before
  will fail on newer node releases. Please update to graceful-fs@^4.0.0 as
  soon as possible*.

 // if I temporarily "ignore" the error and carry on..... 
 // note I notice my npm version was old so altered the system path and now 
 // 3.8.7

mkdir test
cd test
yo WebApp

grunt serve

A valid Gruntfile could not be found. Please see the getting started
guide for  more information on how to configure grunt: 
http://gruntjs.com/getting-started

哦,太好了!

搜索了一下发现这个 http://www.unknownerror.org/opensource/gruntjs/grunt/q/stackoverflow/15483735/quotfatal-error-unable-to-find-local-grunt-quot-when-running-quotgruntquot-comma

module.exports = function(grunt) {

grunt.initConfig({
jshint: {
  files: ['Gruntfile.js', 'App/**/*.js', 'test/**/*.js'],
  options: {
    globals: {
      jQuery: true
    }
  }
 },
watch: {
  files: ['<%= jshint.files %>'],
  tasks: ['jshint']
  }
  });

 grunt.loadNpmTasks('grunt-contrib-jshint');
 grunt.loadNpmTasks('grunt-contrib-watch');

 grunt.registerTask('default', ['jshint']);

 };

现在我遇到了这个错误(我知道未定义服务任务)

咕噜发球 警告:找不到任务“服务”。使用 --force 继续。

在这一点上,我想我现在确实需要询问社区 ;-)。也许我需要验证安装的 Bower 等版本

丹尼尔

【问题讨论】:

  • 当您使用yo webapp 时,它会创建一个名为 webapp 的目录。您必须在其中使用cd webapp 然后grunt serve。否则,请发布您的 gruntfile.js 的全部内容
  • @Ahmad 。感谢您的回复。我检查了我的演示目录,没有 webapp 目录,虽然有一个看起来像迷你网站的应用程序目录。我已经发布了我必须首先创建的完整 grunfile.js,因为它没有生成。你想看看package.json吗。

标签: node.js gruntjs yo


【解决方案1】:

新的 generator-webapp 不再使用 grunt。发电机有几个变化。新的 generator-webapp 现在使用 gulp。

请查看以下安装文档: generator-webapp

【讨论】:

  • 这是正确的,你必须在当前最新版本的generator-webapp中使用gulp serve
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-08-27
  • 2023-04-01
  • 1970-01-01
  • 2017-06-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多