grunt-contrib-jshint icon indicating copy to clipboard operation
grunt-contrib-jshint copied to clipboard

Loading "jshint.js" tasks...ERROR. TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string

Open selvamani-subramani opened this issue 7 years ago • 1 comments

When I run build after npm install I am getting this error. But if I install grunt globally and run grunt build it passes the task.

This is 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']);\""
  }
  ...
}

I am getting the below error when I run 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! [email protected] build: `node -e "require('grunt').tasks(['build']);"`
npm ERR! Exit status 3
npm ERR!
npm ERR! Failed at the [email protected] 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']);

};

When I included require('load-grunt-tasks')(grunt); the error occurred. When I replace to require('load-grunt-tasks')(grunt, {pattern: ['grunt-*', '@*/grunt-*', "!grunt-contrib-jshint"]});, error gone.

https://github.com/gruntjs/grunt-contrib-jshint/issues/277

selvamani-subramani avatar Jan 12 '18 04:01 selvamani-subramani

I am facing the same issue :-) on a Mac.
Node version 11. 5 "devDependencies": { 6 "grunt": "^0.4.5", 7 "grunt-contrib-jshint": "^0.10.0", 8 "grunt-contrib-sass": "^0.8.0", 9 "grunt-contrib-watch": "^0.6.1", 10 "grunt-text-replace": "^0.3.12", 11 "js-yaml": "3.2.*", 12 "load-grunt-tasks": "^3.1.0", 13 "moment": "^2.9.0" 14 }, 21 "directories": { 22 "test": "test" 23 }, 24 "scripts": { 25 "test": "echo "Error: no test specified" && exit 1", 26 "build": "node -e "require('grunt').tasks(['build']);"" 27 },

soundarmoorthy avatar Nov 01 '18 15:11 soundarmoorthy