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

Unexpected token: eof (undefined) error when running task #406

Closed
vivekkodira1 opened this issue May 19, 2016 · 6 comments
Closed

Unexpected token: eof (undefined) error when running task #406

vivekkodira1 opened this issue May 19, 2016 · 6 comments

Comments

@vivekkodira1
Copy link

vivekkodira1 commented May 19, 2016

The error and stack trace are below.
Observations:

  1. If I open and edit the file (any change at any location) and then re-rerun, the task completes without exceptions.
  2. There is no content at the identified location other than a few line-breaks

M/c: mac

{ message: 'Unexpected token: eof (undefined)',
  filename: 'cloudmunch.js',
  line: 28474,
  col: 0,
  pos: 1071559,
  stack: 'Error
  at new JS_Parse_Error (<anonymous>:1526:18)
  at js_error (<anonymous>:1534:11)
  at croak (<anonymous>:2026:9)
  at token_error (<anonymous>:2034:9)
  at unexpected (<anonymous>:2040:9)
  at block_ (<anonymous>:2352:28)
  at eval (<anonymous>:2326:25)
  at function_ (<anonymous>:2331:15)
  at expr_atom (<anonymous>:2546:24)
  at maybe_unary (<anonymous>:2716:19)
  at expr_ops (<anonymous>:2751:24)
  at maybe_conditional (<anonymous>:2756:20)
  at maybe_assign (<anonymous>:2780:20)
  at expression (<anonymous>:2799:20)
  at expr_list (<anonymous>:2565:24)
  at subscripts (<anonymous>:2699:30)
  at expr_atom (<anonymous>:2552:20)
  at maybe_unary (<anonymous>:2716:19)
  at expr_ops (<anonymous>:2751:24)
  at maybe_conditional (<anonymous>:2756:20)
  at maybe_assign (<anonymous>:2780:20)
  at expression (<anonymous>:2799:20)
  at simple_statement (<anonymous>:2240:55)
  at eval (<anonymous>:2113:19)
  at eval (<anonymous>:2073:24)
  at eval (<anonymous>:2827:23)
  at Object.parse (<anonymous>:2837:7)
  at /Users/vivekkodira/cloudmunch/cloudmunch-ui/node_modules/grunt-contrib-uglify/tasks/lib/uglify.js:54:27
  at Array.forEach (native)
  at Object.exports.minify (/Users/vivekkodira/cloudmunch/cloudmunch-ui/node_modules/grunt-contrib-uglify/tasks/lib/uglify.js:37:11)
  at /Users/vivekkodira/cloudmunch/cloudmunch-ui/node_modules/grunt-contrib-uglify/tasks/uglify.js:156:25
  at Array.forEach (native)
  at Object.<anonymous> (/Users/vivekkodira/cloudmunch/cloudmunch-ui/node_modules/grunt-contrib-uglify/tasks/uglify.js:77:16)
  at Object.<anonymous> (/Users/vivekkodira/cloudmunch/cloudmunch-ui/node_modules/grunt/lib/grunt/task.js:264:15)
  at Object.thisTask.fn (/Users/vivekkodira/cloudmunch/cloudmunch-ui/node_modules/grunt/lib/grunt/task.js:82:16)
  at Object.task.fn (/Users/vivekkodira/cloudmunch/cloudmunch-ui/node_modules/jit-grunt/lib/jit-grunt.js:122:30)
  at Object.<anonymous> (/Users/vivekkodira/cloudmunch/cloudmunch-ui/node_modules/grunt/lib/util/task.js:301:30)
  at Task.runTaskFn (/Users/vivekkodira/cloudmunch/cloudmunch-ui/node_modules/grunt/lib/util/task.js:251:24)
  at Task.<anonymous> (/Users/vivekkodira/cloudmunch/cloudmunch-ui/node_modules/grunt/lib/util/task.js:300:12)
  at /Users/vivekkodira/cloudmunch/cloudmunch-ui/node_modules/grunt/lib/util/task.js:227:11
  at process._tickCallback (node.js:355:11)
@avdg
Copy link
Contributor

avdg commented May 19, 2016

Maybe it's better to do that hack for now, if you can send the "corrupt" file.

Pls upload on gist.github.com or so on case someone wants to digg in or when we get more of these issues. Then the bug is at least somewhat documented.

@vivekkodira1
Copy link
Author

Unfortunately, I won't be able to upload the code since it is proprietary. I was able to come up with another workaround to solve the problem. Documenting it here just in case someone else needs it.

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

@avdg
Copy link
Contributor

avdg commented May 20, 2016

hmm it's a bit weird that an error occurs while parsing in a block, bug seems to be uglifyjs side though

(or after concatenating multiple files)

@vivekkodira1
Copy link
Author

Yes. I am concatenating multiple files before running uglify.

@Arkni
Copy link
Member

Arkni commented May 20, 2016

I have seen something like this before. The problem was the grunt-contrib-concat that use CRLF on windows and that cause JSCS to throw a code style error (Invalid line break at ...). So as a solution, you can set grunt.util.linefeed to LF in your Gruntfile:

grunt.util.linefeed = "\u000A";

@edipox
Copy link

edipox commented Jun 10, 2020

In case someone is here because of the uglifyjs error:

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

I got this same error using ember. The solution was to update ember-cli-moment-shim to version v3.8.0

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

5 participants