Error at npm run-script build

By : pmirnd
Source: Stackoverflow.com
Question!

I'm working with ReactJS, compilin with NodeJS. I'm trying toe minify the size of bundle.js.

I'm having this error when I try to build my bundle.js with run-script build

[[email protected]]# npm3 run-script build

> [email protected] build /var/www/XXX/src/FrontendBundle/Resources/public
> NODE_ENV=production browserify boot.js | uglifyjs -cm > bundle.js

Parse error at -:48846,43
SyntaxError: Unexpected token punc «,», expected punc «:»
Error
    at new JS_Parse_Error (eval at <anonymous> (/var/www/XXX/src/FrontendBundle/Resources/public/node_modules/uglify-js/tools/node.js:30:4), <anonymous>:1545:18)
    at js_error (eval at <anonymous> (/var/www/XXX/src/FrontendBundle/Resources/public/node_modules/uglify-js/tools/node.js:30:4), <anonymous>:1553:11)
    at croak (eval at <anonymous> (/var/www/XXX/src/FrontendBundle/Resources/public/node_modules/uglify-js/tools/node.js:30:4), <anonymous>:2092:9)
    at token_error (eval at <anonymous> (/var/www/XXX/src/FrontendBundle/Resources/public/node_modules/uglify-js/tools/node.js:30:4), <anonymous>:2100:9)
    at expect_token (eval at <anonymous> (/var/www/XXX/src/FrontendBundle/Resources/public/node_modules/uglify-js/tools/node.js:30:4), <anonymous>:2113:9)
    at expect (eval at <anonymous> (/var/www/XXX/src/FrontendBundle/Resources/public/node_modules/uglify-js/tools/node.js:30:4), <anonymous>:2116:36)
    at eval (eval at <anonymous> (/var/www/XXX/src/FrontendBundle/Resources/public/node_modules/uglify-js/tools/node.js:30:4), <anonymous>:2689:13)
    at eval (eval at <anonymous> (/var/www/XXX/src/FrontendBundle/Resources/public/node_modules/uglify-js/tools/node.js:30:4), <anonymous>:2139:24)
    at expr_atom (eval at <anonymous> (/var/www/XXX/src/FrontendBundle/Resources/public/node_modules/uglify-js/tools/node.js:30:4), <anonymous>:2619:35)
    at maybe_unary (eval at <anonymous> (/var/www/XXX/src/FrontendBundle/Resources/public/node_modules/uglify-js/tools/node.js:30:4), <anonymous>:2795:19)

npm ERR! Linux 3.10.0-327.10.1.el7.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/lib/node_modules/npm3/node_modules/npm/cli.js" "run-script" "build"
npm ERR! node v0.12.7
npm ERR! npm  v3.9.0
npm ERR! code ELIFECYCLE
etc...

In another similar question, the answer was go to the line,column: 48846,43 and see if there's a colon or something but there's not, actually there's no column 43 in that line of my bundle.js (made it with normal nmp3 start)

any help? thanks

By : pmirnd


Answers

I was defining some ajax like this:

$.ajax({
    url:path.url_estructura_eliminar_seccion,
    type:"post", dataType:"json", data:{id},
    success : function(obj) {
        if( obj.success )
            Store.emit("editSectionSuccess");
        else
            Store.emit("errorOnEdit");
    },
    error: function() { Store.emit("errorOnEdit"); }
});

The problem was solved with data:{id:id}, but don't know why when I compile with Node.js it works, only uglifyjs makes the warnings.

By : pmirnd


It seems to be a typo, you probably put a , instead of a : in a JSON object.

var obj = {
  "data", "15"
}

UPDATE

The the best workaround that come to my mind is to install eslint an verify for errors.

  • Run npm i -g eslint.
  • Run eslint --init to create a configuration file.
  • Choose the configuration according to the type of files you're working on.
  • Run eslint command.
By : byoigres


You need a logical condition in the while. Perhaps

program.toUpperCase().equals("Y")
By : nicomp


This video can help you solving your question :)
By: admin