Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gulp html task got Unknown Word error #572

Closed
redodonut opened this issue Sep 19, 2016 · 26 comments
Closed

Gulp html task got Unknown Word error #572

redodonut opened this issue Sep 19, 2016 · 26 comments

Comments

@redodonut
Copy link

I've execute gulp html inside of my new folder yeoman-webapp generated project

oyt@oyt:~/yeoman/new$ gulp html
[05:39:27] Requiring external module babel-register
[05:39:32] Using gulpfile ~/yeoman/new/gulpfile.babel.js
[05:39:32] Starting 'styles'...
[05:39:33] Starting 'scripts'...
[05:39:39] Finished 'styles' after 7.16 s
[05:39:40] Finished 'scripts' after 6.64 s
[05:39:40] Starting 'html'...

Then an error was appeared

events.js:160
throw er; // Unhandled 'error' event
^
Error: /home/oyt/yeoman/new/index.html:1:1: Unknown word> 1 |
| ^
2 |
3 |

I have checked anything related with it, fundamentally from gulp.task function inside of the gulpfile.babel.js but i don't understand yet. I have no change with my gulp html function task... (still default)

gulp.task('html', ['styles', 'scripts'], () => {
return gulp.src('app/.html')
.pipe($.useref({searchPath: ['.tmp', 'app', '.']}))
.pipe($.if('
.css', $.cssnano()))
.pipe($.if('*.html', $.htmlmin({collapseWhitespace: true})))
.pipe(gulp.dest('dist'));
});

Beside of that, I have also checked the html file format and i think it's Okay (no error) with a sublime linter.

@silvenon
Copy link
Member

silvenon commented Oct 2, 2016

I'm curious about those conditional comments for IE7, as we don't have those. What did you change exactly and which version of generator did you scaffold your project with?

@martisj
Copy link

martisj commented Oct 18, 2016

I've got a similar error with v2.0.0 of the generator. uglify seems to be throwing an error

[13:03:48] Plumber found unhandled error:
 Error in plugin 'gulp-uglify'
Message:
    {...}/app/index.html: SyntaxError: Unexpected token: operator (<)
Details:
    fileName: {...}/app/index.html
    lineNumber: 1

@silvenon
Copy link
Member

silvenon commented Nov 6, 2016

It looks like gulp-uglify is trying to parse HTML, I wonder why…

Does this happen on fresh install or are there some steps to reproduce this? There have been few releases since v2.0.0, does upgrading and building again help?

@michael2h4ng
Copy link

@silvenon I've encountered the same issue on a fresh install.

After commenting out line 57 and 58 in gulpfile.babel.js, it ran as normal. It looks like both gulp-uglify and gulp-cssnano were trying to parse HTML. Could it be something wrong with gulp-if?

@silvenon
Copy link
Member

@monomichael maybe, does it help to update gulp-if, if you don't already have the latest version?

@michael2h4ng
Copy link

@silvenon Yes, it does. After updating gulp-if to 2.0.2, the issue no longer exists.

@silvenon
Copy link
Member

Awesome! In the recent versions of generator-webapp we already have gulp-if updated, so hopefully this isn't an issue anymore. I will gladly reopen if someone still has problems with this. 😉

@sherifsaleh
Copy link

I still have the same problem eventhough i ihave gulp-if updated to 2.0.2

[21:39:12] CLI version 1.2.2
[21:39:12] Local version 3.9.1
"gulp-if": "^2.0.2"
node v7.1.0

@silvenon
Copy link
Member

@sherifsaleh does this happen on a fresh install? Did you modify anything else? Is your gulp-useref up-to-date?

@hamedtaha
Copy link

i'm also having the same problem

"gulp-if": "^2.0.2"
node v6.9.3

@silvenon
Copy link
Member

@hamedtaha are you using the latest version of generator-webapp?

@hamedtaha
Copy link

hamedtaha commented Feb 15, 2017

Yes I have the latest 'web-app' generator
I'm trying to build my code then I got that error

@silvenon
Copy link
Member

@hamedtaha so this happens on a fresh install or did you modify anything? Could you paste your gulpfile.js?

@hamedtaha
Copy link

hamedtaha commented Feb 17, 2017

In my HTML code I've Used a code formatter plugin (in sublime text)
and it changed some spaces , this line was causing the error

<!-- build:js scripts/vendor/modernizr.js --> <script src="/bower_components/modernizr/modernizr.js" type="text/javascript"> </script><!-- [new line] [new line] endbuild [new line] -->

when i changed it to
<!-- build:js scripts/vendor/modernizr.js --> <script src="/bower_components/modernizr/modernizr.js" type="text/javascript"></script> <!-- endbuild -->

then the 'gulp' command went fine and it builds the 'dist' code , but without any js or css linking :( that also was strange

@silvenon
Copy link
Member

silvenon commented Feb 17, 2017

I don't understand. The [new line] that you described don't match the generated index.html. It should look like this: <!-- build:js scripts/vendor/modernizr.js -->[new line]<script src="/bower_components/modernizr/modernizr.js" type="text/javascript"></script>[new line]<!-- endbuild -->

Could you paste your index.html?

@hamedtaha
Copy link

hamedtaha commented Feb 17, 2017

when I paste my HTML here the website removes all whitespaces
but here is a screenshot of the code

errors was because of the white spaces

before
and here the gulp task is building with no errors

after

after that, it is working
but all the background-images in the SCSS files have a wrong path

@silvenon
Copy link
Member

silvenon commented Feb 17, 2017

This:

<!--
endbuild
    -->

couldn't have happened with our setup, you did that somehow. Maybe that's what was throwing gulp-useref off.

How are background images related? Also, those URLs aren't processed in any way.

@hamedtaha
Copy link

sublime text HTML code formatting plugin caused that
and the background images issue I think that is a problem from my side

@silvenon
Copy link
Member

Ok, let's back up 😄 what is the issue exactly?

@hamedtaha
Copy link

:D
the error was a javascript parsing error
events.js:141
throw er; // Unhandled 'error' event
^

@silvenon
Copy link
Member

But you said that it's working after fixing that endbuild whitespace, or?

@hamedtaha
Copy link

yes after fixing the white spaces everything is working now

@PlkMarudny
Copy link

PlkMarudny commented Mar 22, 2017

I have the same problem, gulp-webapp downloaded on 21st march, a clean project without Bootstrap, Windows,

`[20:05:42] Starting 'html'...

events.js:160
throw er; // Unhandled 'error' event
^
Error
at new JS_Parse_Error (eval at (C:\Users\toplonka\Documents\js\test\node_modules\uglify-js\tools\node.js:28:1), :1534:18)`

@neilhem
Copy link
Collaborator

neilhem commented Mar 23, 2017

@PlkMarudny looks like you have invalid javascript code

@PlkMarudny
Copy link

I have just tried to build a clean project, no javascript on my own; scaffolder and tried to build.

@neilhem
Copy link
Collaborator

neilhem commented Mar 23, 2017

I recommend updating dependencies via rm -rf node_modules && npm install, also check project dependencies outdated or not via npm outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants