当我在npm install之后运行build时,我收到此错误。但是如果我在全局安装grunt并运行grunt build
,它就会通过任务。
这是package.json
{
...
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-sass": "^0.8.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-text-replace": "^0.3.12",
"js-yaml": "3.2.*",
"load-grunt-tasks": "^3.1.0",
"moment": "^2.9.0",
"grunt-contrib-jshint": "^0.10.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "node -e \"require('grunt').tasks(['build']);\""
}
...
}
运行npm run build
Loading "jshint.js" tasks...ERROR
>> TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string
Warning: Task "jshint" not found. Use --force to continue.
Aborted due to warnings.
npm ERR! code ELIFECYCLE
npm ERR! errno 3
npm ERR! superapp@1.0.0 build: `node -e "require('grunt').tasks(['build']);"`
npm ERR! Exit status 3
npm ERR!
npm ERR! Failed at the superapp@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Mac/.npm/_logs/2018-01-12T04_27_38_104Z-debug.log
我的gruntfile.js
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
...
});
// Register Task Aliases
grunt.registerTask('styles', ['sass', 'replace']);
grunt.registerTask('base', ['jshint', 'styles']);
grunt.registerTask('build', ['base', 'yaml']);
grunt.registerTask('default', ['base', 'watch']);
};