In the book “Automatic Construction of Web Front End”, according to the second chapter “Introduction to Gulp”, in order to use JSHint to conduct code style check, after installing Gulp-Jshint, I wrote the following example code:
const jshint = require('gulp-jshint');
gulp.task('test', () => {
return gulp.src('./app/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'))
});
When running gulp test
, the following error occurs:
module.js:442
throw err;
^
Error: Cannot find module 'jshint/src/cli'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (E:\Nodejs\mywebpackDemo\node_modules\gulp-jshint\src\extract.js:1:79)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
Analysis of the
The console reports an error and cannot find Jshint. The easiest way to resolve this error is to install the package that cannot be found.
The solution
NPM install --save-dev jshint
When using JSHint for code style checking, JSHint
and gulp-jshint
can be installed directly once.
namely:
NPM install --save-dev jshint gulp-jshint
Reference articles:
https://stackoverflow.com/questions/33984558/gulp-error-cannot-find-module-jshint-src-cli
Read More:
- Cannot find module ‘internal / util / types’ appears during gulp build
- When starting Vue project: cannot find module ‘webpack cli/bin/config yargs’ error [How to Fix]
- Cannot find module ‘webpack cli / bin / config yargs‘
- NPM run dev error: cannot find module ‘webpack cli / bin / config yargs‘
- ./src/router/index.js Module not found: Error: Can‘t resolve ‘@/views/tet_demo‘ in ‘D:\admin\src\rou
- Gulp error report, assertionerror [err_ ASSERTION]: Task function must be specified
- Error in adding jshint plug-in to vscode
- Error: Cannot find module ‘process-nextick-args’
- NPM- Cannot find module ‘xxxxx’
- [Solved] Error: Cannot find module ‘webpack/lib/RequestShortener’
- Solved – problem cannot find module ‘webpack / bin / config yargs’
- Error reported by gulp: referenceerror: primordials is not defined
- Module build failed (from ./node_modules/postcss-loader/src/index.js):
- Error: cannot find module ‘mongoose’
- Module build failed: error: cannot find module ‘node sass’ error
- Error reported after moving or copying Vue items: cannot find module ‘xxx‘
- Unable to find or load master class org.codehaus.groovy.grails.cli.support
- Error: Cannot find module’webpack/bin/config-yargs’ solution
- Gulp failed to run
- This relative module was not found: * ./store in ./src/main.js