问题描述
我的应用是用 Reactjs 制作的.
I have my app made with Reactjs.
当我尝试运行 npm run-script build
时,我得到了这个错误:
I'm gettint this error when I try to run npm run-script build
:
ERROR in bundle.js from UglifyJs
SyntaxError: Unexpected token: name (x) [./react/stores/UserStore.js:52,20]
ERROR in bundle.js from UglifyJs
SyntaxError: Unexpected token: name (x) [./react/stores/UserStore.js:52,20]
错误被抛出两次.并注释了指向文件的行!现在我尝试不使用这些行,但仍然遇到相同的错误.但这是我第一次遇到这个错误,不知道为什么,而且我已经好几个星期没有碰过那个文件了...
The error is thrown twice. And the line of the file that is poiting is commented!And now I try without those lines and I'm still getting the same error.But this is the first time that I have this error, don't know why, and i haven't touched that file in weeks...
有什么想法吗?
推荐答案
好吧,就我而言,我没有 babel-preset-es2015
所以:
Well, in my case was that I didn't have babel-preset-es2015
so:
npm install --save-dev babel-preset-es2015
- 在 webpack-production.config.js 中添加 es2015,像这样:
['es2015', 'es2016', 'react']
Uglify 将使用 es6 代码(es6 -[babel preset es2015]-> es5 -> webpack with uglify plugin -> done)
The Uglify will work with es6 code (es6 -[babel preset es2015]-> es5 -> webpack with uglify plugin -> done)
这篇关于来自 UglifyJs SyntaxError 的 bundle.js 中的错误:意外标记:名称 (x)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!