gulp-strip-comments
gulp-strip-comments copied to clipboard
Unespected token ILLEGAL - esprima.js
C:\wamp\www\reiPallet\node_modules\gulp-strip-comments\node_modules\decomment\node_modules\esprima\dist\esprima.js:3391 throw error; ^ Error: Line 1: Unexpected token ILLEGAL at ErrorHandler.constructError (C:\wamp\www\reiPallet\node_modules\gulp-strip-comments\node_modules\decomment\node_modules\esprima\dist\esprima.js:3396:22) at ErrorHandler.createError (C:\wamp\www\reiPallet\node_modules\gulp-strip-comments\node_modules\decomment\node_modules\esprima\dist\esprima.js:3414:27) at ErrorHandler.throwError (C:\wamp\www\reiPallet\node_modules\gulp-strip-comments\node_modules\decomment\node_modules\esprima\dist\esprima.js:3422:21) at Scanner.throwUnexpectedToken (C:\wamp\www\reiPallet\node_modules\gulp-strip-comments\node_modules\decomment\node_modules\esprima\dist\esprima.js:3505:28) at Scanner.scanPunctuator (C:\wamp\www\reiPallet\node_modules\gulp-strip-comments\node_modules\decomment\node_modules\esprima\dist\esprima.js:4026:19) at Scanner.lex (C:\wamp\www\reiPallet\node_modules\gulp-strip-comments\node_modules\decomment\node_modules\esprima\dist\esprima.js:4628:22) at Tokenizer.getNextToken (C:\wamp\www\reiPallet\node_modules\gulp-strip-comments\node_modules\decomment\node_modules\esprima\dist\esprima.js:6366:43) at Object.tokenize (C:\wamp\www\reiPallet\node_modules\gulp-strip-comments\node_modules\decomment\node_modules\esprima\dist\esprima.js:136:36) at Object.parseRegEx (C:\wamp\www\reiPallet\node_modules\gulp-strip-comments\node_modules\decomment\lib\utils.js:37:13) at parser (C:\wamp\www\reiPallet\node_modules\gulp-strip-comments\node_modules\decomment\lib\parser.js:34:27)
I get this error message when try to run the gulp task, I tryed to solve the error but it was unsuccessful.
So you must be sending an invalid javascript file into it.
I just remove all the .js files in my project and get the same error.
- Find which file + extension it complains about
- Post either the while file here or the line where it complains
- Post which
decomment
method you are using to process the file
Then it will be possible to assist you further.
Same issue, there is a problem when you specify wildcards such as '/**/*' in the gulp.src preceding the strip task.
What happens is that the file discovery in the through.obj call goes up a directory and loads files from there.
Given this file structure
root
src\
dest\
gulpfile.js
Using this gulp command
return gulp.src('dest/*/**''] )
.pipe(strip())
.pipe(gulp.dest('dest'));
Will actually load files from 'root/**' and not just from 'root/dest/'
@sverrirs try gulp-decomment
instead, which does the same ;)
I solved this issue by rewriting division statements.
Original:
var lng = _.reduce(userList, function(memo, userElement) {
if (userElement.location.coordinates[0] !== 0) {
j++;
return memo + userElement.location.coordinates[0];
}
else
return memo;
}, 0) / (j === 0 ? 1 : j);
Fix:
var lng = _.reduce(userList, function(memo, userElement) {
if (userElement.location.coordinates[0] !== 0) {
j++;
return memo + userElement.location.coordinates[0];
}
else
return memo;
}, 0);
lng = lng / (j === 0 ? 1 : j);
@sverrirs try
gulp-decomment
instead, which does the same ;)
Produces exactly the same error though
I am having this issue with private class members - for both gulp-decomment and gulp-strip-comments. Perhaps the parser(s) used by these libs are not up to date with the latest syntax.
Nevermind those are a Node.js 12 language feature, and I'm using version 11!
Well, updating node.js didn't fix the issue - but my error message looks nicer now
Node version:
16.14.0
[14:17:22] Error in plugin "gulp-strip-comments"
Message:
Line 4773: Unexpected token ILLEGAL
Details:
index: 308968
lineNumber: 4773
description: Unexpected token ILLEGAL
fileName: C:\my\file\path.js
Process terminated with code 1.