【问题标题】:Grunt reference error咕噜声参考错误
【发布时间】:2014-08-05 10:48:15
【问题描述】:

Gruntfile.js

   module.exports = functions(grunt)
    {
     grunt.initConfig({
   //pkg: grunt.file.readJSON('package.json'),
     concat: {
    options: {
        separator: ';',
    },
       dist: {
        src:   ['APIdocu/AccountsCollection.md', 'APIdocu/AccountsFollowersCollection.md'],
    dest: 'APIdocu/ConcatApis.md',
        //files: {
            //'APIdocu/NewApi.md' : ['APIdocu/AccountsCollection.md', 'APIdocu/AccountsFollowersCollection.md']
        },
},
});

grunt.loadNpmTasks('grunt-contrib-concat');
//tasks
grunt.registerTask('default', ["concat"]);
 }

错误信息

Initializing
Command-line options: --verbose

Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.
Loading "Gruntfile.js" tasks...ERROR
ReferenceError: grunt is not defined
at Object.<anonymous> (C:\Users\gs1460\Desktop\Markdownfiles\apis\Gruntfile.js:1:90)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at loadTask (C:\Users\gs1460Desktop\Markdownfiles\apis\node_modules\grunt\lib\grunt\task.js:323:10)
at Task.task.init (C:\Users\gs1460\Desktop\Markdownfiles\apis\node_modules\grunt\lib\grunt\task.js:437:5)
at Object.grunt.tasks (C:\Users\gs1460\Desktop\Markdownfiles\apis\node_modules\grunt\lib\grunt.js:120:8)
at Object.module.exports [as cli] (C:\Users\gs1460\Desktop\Markdownfiles\apis\node_modules\grunt\lib\grunt\cli.js:38:9)

    Running tasks: concat:dist
    Warning: Task "concat:dist" not found. Use --force to continue.
    Aborted due to warnings.

如何摆脱这个错误。 我需要将 md 文件连接到一个。它给了我上述错误。多次尝试更改代码。但同样的问题。你能帮忙吗?

【问题讨论】:

  • 您是否在全球范围内安装了grunt/grunt-cli

标签: node.js gruntjs grunt-contrib-concat grunt-cli


【解决方案1】:

问题可能是您写的是functions 而不是function。 还要检查变量 grunt 是否在正确的范围内。并且请正确使用标签!

module.exports = function(grunt)

问候。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-10
    • 2014-07-25
    • 1970-01-01
    • 1970-01-01
    • 2020-03-11
    • 2013-03-07
    • 1970-01-01
    • 2014-02-26
    相关资源
    最近更新 更多