【发布时间】: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
哦,太好了!
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吗。