npm run-script build出错

时间:2016-09-28 22:28:13

标签: node.js reactjs npm

我正在使用ReactJS,与NodeJS合作。我正在努力缩小bundle.js的大小。

当我尝试使用run-script build

构建我的bundle.js时出现此错误
[root@XXX]# npm3 run-script build

> public@1.0.0 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...

在另一个类似的问题中,答案是行,专栏:48846,43 并查看是否有冒号或其他东西,但没有,实际上我的bundle.js的那一行中没有第43列(使用正常的nmp3开始)

任何帮助?感谢

2 个答案:

答案 0 :(得分:0)

这似乎是一个错字,您可能在JSON对象中放置了,而不是:

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

<强>更新

我想到的最佳解决方法是安装eslint验证错误。

  • 运行npm i -g eslint
  • 运行eslint --init以创建配置文件。
  • 根据您正在处理的文件类型选择配置。
  • 运行eslint命令。

答案 1 :(得分:0)

我正在定义一些像这样的ajax:

$.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"); }
});

问题是通过数据解决的:{id:id},但不知道为什么当我使用Node.js进行编译时,只有uglifyjs会发出警告。