javascript uglify js错误意外标记eof“未定义”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13634049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
uglify js error unexpected token eof "undefined"
提问by Evan
So I installed npm using npm install uglify-js
所以我使用 npm install uglify-js 安装了 npm
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?
关于这是关于什么或我应该如何解决它的任何想法?
采纳答案by C???
ERROR: Unexpected token eof ?undefined?, expected punc ?,? [-:630,15]
错误:意外的标记 eof ?undefined?,预期的 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.
我相信这意味着您缺少,
JS 代码中的某个地方,可能在第 630 行,靠近字符 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.
因此,如果您连接所有 JS 文件的源代码,并查看第 630 行,您可能会发现解析器认为缺少逗号的位置。
回答by Abhijit Rao
This could also be because of a bug in UglifyJS when reading from stdin. See https://github.com/mishoo/UglifyJS2/issues/85for details.
这也可能是因为从标准输入读取时 UglifyJS 中的错误。有关详细信息,请参阅https://github.com/mishoo/UglifyJS2/issues/85。
回答by mcsharps
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.
就我而言,我忘记关闭我的 javascript 中的一些打开的函数。确保您也正确关闭了所有分号。
回答by Vivek Kodira
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.
也面临同样的问题。但是,就我而言,我可以打开有问题的文件并保存它,然后 uglify 就可以正常运行了。
Documented here
记录在这里
Workaround: I added a lineendingtask before invoking uglify to explicitly convert the line endings. Now uglify runs without issues.
解决方法:在调用uglify以显式转换行尾之前,我添加了一个行尾任务。现在 uglify 运行没有问题。