Element: [Bug, Report], NPM, run, build, Error

Created on 3 Jun 2017  ·  30Comments  ·  Source: ElemeFE/element

Element UI version

1.3.4

OS/Browsers version

Mac/safari

Vue version

2.3.3

Reproduction Link

https://jsfiddle.net/xryt9b4j/2/

Steps to reproduce

npm run build error
ERROR in static/js/vendor.e009106343d3b31cf28f.js from UglifyJs
Unexpected token punc «(», expected punc «:» [./~/element-ui/packages/col/src/col.js:23,0][static/js/vendor.e009106343d3b31cf28f.js:146795,10].

用npm run dev is Ok

What is Expected?

修复Bug

What is actually happening?

修复Bug

Most helpful comment

module: {
    rules:[
       {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('src'), resolve('test'),resolve('/node_modules/element-ui/src'),resolve('/node_modules/element-ui/packages')]
      },
   ]
}

it's works for me.

All 30 comments

Translation of this issue:

Element UI version

1.3.4

OS/Browsers version

Mac/safari

Vue version

2.3.3

Reproduction Link

https://jsfiddle.net/xryt9b4j/2/

Steps to reproduce

NPM run build error

ERROR, in, static/js/vendor.e009106343d3b31cf28f.js, from, UglifyJs
Unexpected token punc ("expected punc", "[./~/element-ui/packages/col/src/col.js:23,0][static/js/vendor.e009106343d3b31cf28f.js:146795,10].":

With NPM run, dev, is, Ok

What is Expected?

Repair Bug

What is actually happening?

Repair Bug

  1. 不要直接引入未编译的代码
  2. 不要乱加与 issue 无关的 demo

I have the same problem. Is there a way to fix it?

I have the same problem. can somebody fix it?

I have the same problem

ERROR in index.js?797e177ae8445502fcbd from UglifyJs Unexpected token punc «(», expected punc «:» [./~/element-ui/packages/col/src/col.js:23,0][index.js?797e177ae8445502fcbd:3929,10]

same issue here . any fix?

Keep Element from being processed by UglifyJS.

module: {
    rules:[
       {
        test: /\.js$/,
        loader: 'babel-loader',
        include: [resolve('src'), resolve('test'),resolve('/node_modules/element-ui/src'),resolve('/node_modules/element-ui/packages')]
      },
   ]
}

it's works for me.

@Leopoldthecoder Thanks, it resolves my problem.

@jackie19 very useful!

@jackie19 thank you,it's useful!

Same error:
this error is occuring after updating it from older version 1.4.2 to newer version.

What is the real cause?

not work, any update ??

@jackie19 work for me too

When I added this line:
[resolve('src'), resolve('test'),resolve('/node_modules/element-ui/src'),resolve('/node_modules/element-ui/packages')]
i've got this error:
"resolve is not defined"

your version of uglify doesn't support es6 and needs to be updated. The latest version could be gained as separate plugin

webpack =< v3.0.0 currently contains v0.4.6 of this plugin under webpack.optimize.UglifyJsPlugin as an alias. For usage of the latest version (v1.0.0), please follow the instructions below. Aliasing v1.0.0 as webpack.optimize.UglifyJsPlugin is scheduled for webpack v4.0.0

Please refer to https://webpack.js.org/plugins/uglifyjs-webpack-plugin/

Once you will install v1.0.0 you will be able to build it

@Daeghun Thank you, it's helped.

resolve a function that you need to customize
like this:
function resolve (dir) {
return path.join(__dirname, '..', dir)
}

@exmozz

@Daeghun should every one update the uglify plugins?

兄弟,我也遇到这样的问题 ,可以帮下忙嘛 @QingWei-Li

是不是element不能在浏览器用?

是在打包的时候出现问题
image

我看了一下 element ui 的这个文件语法没有被转换成es5

image

我试了上面的方法解决不了 很难过

我用的webstorm, 直接写一个组件的标签的时候编译器会自动的帮你import某个单独的组件,而且会直接在export default里面的components里添加进去,把这两部分删掉就不会报错了,就是和 @QingWei-Li 说的一样,你引入了未编译的代码,所以才会报这个问题 @FAKER-A

后来在code review的时候发现是有个实习生直接引用了没有打包的组件的问题

@yusphy45 我也出现了这个问题,看了你的评论果然是webstorm单独引入了组件,去掉之后就好了,感谢。

我的问题是和@yusphy45 一样的,都是webstorm引入了组件的source code造成的,谢谢。不知道为什么 @weituotian 会给 👎 ....

终于解决了,注意node_modules前边没有/

{
    test: /\.js$/,
        use: 'babel-loader',
    // exclude: /node_modules/,
    include: [
        resolve('src'),
        resolve('test'),
        resolve('node_modules/element-ui/src'),
        resolve('node_modules/element-ui/packages'),
        resolve('node_modules/vue-echarts-v3')
    ]
},

发现~vue-echarts这个组件也会有这个问题。。。

那我没有用element-ui咋搞呢

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yorululu picture yorululu  ·  3Comments

EdenSpark picture EdenSpark  ·  3Comments

no5no6 picture no5no6  ·  3Comments

Kingwl picture Kingwl  ·  3Comments

smallpath picture smallpath  ·  3Comments