uglify js error unexpected token eof "undefined"
Asked Answered
P

6

7

So I installed npm using npm install uglify-js

I run a command which is:

cat file1.js file2.js .. fileN.js | uglifyjs -o files.min.js

and I get this error:

WARN: ERROR: Unexpected token eof «undefined», expected punc «,» [-:630,15]

/usr/local/lib/node_modules/uglify-js/lib/parse.js:199
    throw new JS_Parse_Error(message, line, col, pos);
          ^
Error
    at new JS_Parse_Error (/usr/local/lib/node_modules/uglify-js/lib/parse.js:185:18)
    at js_error (/usr/local/lib/node_modules/uglify-js/lib/parse.js:199:11)
    at croak (/usr/local/lib/node_modules/uglify-js/lib/parse.js:630:9)
    at token_error (/usr/local/lib/node_modules/uglify-js/lib/parse.js:638:9)
    at expect_token (/usr/local/lib/node_modules/uglify-js/lib/parse.js:651:9)
    at expect (/usr/local/lib/node_modules/uglify-js/lib/parse.js:654:36)
    at ctor.argnames (/usr/local/lib/node_modules/uglify-js/lib/parse.js:897:52)
    at function_ (/usr/local/lib/node_modules/uglify-js/lib/parse.js:902:15)
    at expr_atom (/usr/local/lib/node_modules/uglify-js/lib/parse.js:1114:24)
    at maybe_unary (/usr/local/lib/node_modules/uglify-js/lib/parse.js:1278:19)

Any ideas on what this is about or how I should go about fixing it?

Petr answered 29/11, 2012 at 20:21 Comment(0)
C
7

ERROR: Unexpected token eof «undefined», expected punc «,» [-:630,15]

I believe all it means is that you are missing a , somewhere in your JS code, possibly on line 630, near character 15.

So if you concatenate the source of all your JS files, and take a look at line 630, you might find where the parser thought there was a missing comma.

Chateau answered 29/11, 2012 at 20:24 Comment(0)
G
5

I got this same error with ember:

Build Error (UglifyWriter)
Unexpected token: eof (undefined)

The solution was to update ember-cli-moment-shim to version v3.8.0

Geis answered 10/6, 2020 at 18:58 Comment(0)
A
2

This could also be because of a bug in UglifyJS when reading from stdin. See https://github.com/mishoo/UglifyJS2/issues/85 for details.

Antofagasta answered 14/3, 2013 at 22:31 Comment(0)
H
1

In my case I had forgotten to close some open functions in my javascript. Make sure you have all of your semicolons properly closed too.

Hyacinthia answered 20/4, 2015 at 13:34 Comment(0)
G
1

I also had this error. My project was getting error on docker build while compiling successfully on my local machine. Because of version of node. I solved the problem by giving node dependency to the package.json file.

This version solved my issue:
"node":"12.22.3"

Groundsill answered 1/9, 2021 at 17:2 Comment(0)
D
0

Also faced this same issue. However, in my case, I could open the file with a problem and save it and then uglify would run without any issues.

Documented here

Workaround: I added a lineending task before invoking uglify to explicitly convert the line endings. Now uglify runs without issues.

Disinterested answered 20/5, 2016 at 9:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.