我的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"]);
};
(我正在使用grunt-ts。)
系统信息
我已经在互联网上搜索了很多有关此错误的资源,但他们都说应该升级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.
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"
}
}
答案 0 :(得分:16)
将我的Gruntfile与官方提供的sample file进行比较后,我发现真的很傻错误:
ts: {
dev: {
src: ["src/background/*.ts"],
out: ["build/background.js"],
}
}
out
不得成为阵列!
正确的版本:
ts: {
dev: {
src: ["src/background/*.ts"],
out: "build/background.js",
}
}
答案 1 :(得分:2)
因此,在我的特定情况下,main
中的节点模块package.json
属性是一个数组而不是字符串,例如history.js&#39;的package.json:
{
"main": [ './history.js', './history.adapter.ender.js' ]
}
我发现这种情况的方式是在我的node_modules中发生错误,然后在它上方console.log(pkg.main)
。
原始堆栈跟踪:
Fatal error: Arguments to path.resolve must be strings
TypeError: Arguments to path.resolve must be strings
at Object.posix.resolve (path.js:422:13)
at /Users/ebower/work/renvy/node_modules/browserify/node_modules/resolve/lib/async.js:153:38
at fs.js:336:14
at /Users/ebower/work/renvy/node_modules/grunt-browserify/node_modules/watchify/node_modules/chokidar/node_modules/readdirp/node_modules/graceful-fs/graceful-fs.js:104:5
at /Users/ebower/work/renvy/node_modules/grunt-mocha/node_modules/mocha/node_modules/glob/node_modules/graceful-fs/graceful-fs.js:104:5
at FSReqWrap.oncomplete (fs.js:99:15)