2017-02-20 14 views
0

これはgruntの私の最初のテストです:)とにかく、私は別のgruntモジュールを使用してjavasrciptコードをテストしたいと思います。それらはすべてインストールされており、package.jsonというjsonファイルでそれらを見ることができます。不平は定義されていません - AngularJs

{ 
    "name": "LarissaCity", 
    "private": true, 
    "devDependencies": { 
    "grunt": "^1.0.1", 
    "grunt-contrib-jshint": "^1.1.0", 
    "jit-grunt": "^0.10.0", 
    "jshint-stylish": "^2.2.1", 
    "time-grunt": "^1.4.0" 
    }, 
    "engines": { 
    "node": ">=0.10.0" 
    } 
} 

次に、Gruntfile.jsというファイルがあります。そして、その内部には、インストールされたモジュールを使用してJavaScriptコードをテストします。そう。

'use strict'; 

// Time how long tasks take. Can help when optimizing build times 
require('time-grunt')(grunt); 

// Automatically load required Grunt tasks 
require('jit-grunt')(grunt); 

// Define the configuration for all the tasks 
grunt.initConfig({ 
pkg: grunt.file.readJSON('package.json'), 

// Make sure code styles are up to par and there are no obvious mistakes 
jshint: { 
options: { 
    jshintrc: '.jshintrc', 
    reporter: require('jshint-stylish') 
}, 

all: { 
    src: [ 
    'Gruntfile.js', 
    'app/scripts/{,*/}*.js' 
    ] 
    } 
} 
}); 

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

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

私はCMDでイサキを入力すると、これがアップします。

Loading "Gruntfile.js" tasks...ERROR 
ReferenceError: grunt is not defined 

多分、Gruntfile.jsに何か問題があります。何か案は?ありがとう、

Theo。

+2

に以下のブロックでコードを記述する必要がありますか? –

+0

oops。私はしませんでした。私はもう一度やり直します。 – Theo

+0

はい、動作しています! – Theo

答えて

1

あなたは ``( 'うなり声を')必要でしたgruntfile.js

module.exports = function(grunt){ 
     //Your code here 
    } 
関連する問題