运行Grunt时,path.resolve的参数必须是字符串

Com*_*eek 12 node.js npm gruntjs

我的Grunt档案:

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        ts: {
            dev: {
                src: ["src/background/*.ts"],
                out: ["build/background.js"],
            }
        }
    });

    grunt.loadNpmTasks("grunt-ts");
    grunt.registerTask("default", ["ts:dev"]);
};
Run Code Online (Sandbox Code Playgroud)

(我正在使用grunt-ts.)

系统信息

  • Windows 8.1
  • NodeJS v0.10.24
  • grunt-cli v0.1.11
  • 咕噜v0.4.2

我已经在互联网上搜索了很多有关此错误的资源,但他们都说应该升级NodeJS和/或Grunt.我已经尝试过了.我甚至完全重新安装了Grunt,但错误仍然存​​在.


完整的错误消息:

P:\my-folder>grunt ts
Running "ts:dev" (ts) task
Warning: Arguments to path.resolve must be strings Use --force to continue

Aborted due to warnings.
Run Code Online (Sandbox Code Playgroud)

package.json

{
  "name": "regex-search",
  "version": "0.1.0",
  "devDependencies": {
    "grunt": "~0.4.2",
    "grunt-contrib-jshint": "~0.6.3",
    "grunt-contrib-nodeunit": "~0.2.0",
    "grunt-contrib-uglify": "~0.2.2",
    "grunt-ts": "~1.5.1"
  }
}
Run Code Online (Sandbox Code Playgroud)

Com*_*eek 16

在将我的Gruntfile与官方提供的示例文件进行比较后,我发现了一个非常愚蠢的错误:

ts: {
  dev: {
    src: ["src/background/*.ts"],
    out: ["build/background.js"],
  }
}
Run Code Online (Sandbox Code Playgroud)

out 一定不能是阵列!
正确的版本:

ts: {
  dev: {
    src: ["src/background/*.ts"],
    out: "build/background.js",
  }
}
Run Code Online (Sandbox Code Playgroud)