一个 vue2.0 项目,执行 npm run dev 正常,但是 npm run build 出现打包错误,
xxx@xxx:~/xxx/src/frontend$ npm run build
> test@1.0.0 build /home/xxx/src/frontend
> node build/build.js
Hash: 4003cde5faa0b066a0a7
Version: webpack 3.8.1
Time: 8660ms
Asset Size Chunks Chunk Names
static/js/vendor.e475838be75c71f87b37.js 1.72 MB 0 [emitted] [big] vendor
static/js/app.bf4b159892d6feccb271.js 13.6 kB 1 [emitted] app
static/js/manifest.01542bfecf9357fb0249.js 1.49 kB 2 [emitted] manifest
static/css/app.9746d34b80301e3f963132f72e9f5f23.css 106 kB 1 [emitted] app
static/js/vendor.e475838be75c71f87b37.js.map 2.13 MB 0 [emitted] vendor
static/js/app.bf4b159892d6feccb271.js.map 68.5 kB 1 [emitted] app
static/js/manifest.01542bfecf9357fb0249.js.map 14.2 kB 2 [emitted] manifest
index.html 829 bytes [emitted]
ERROR in static/js/vendor.e475838be75c71f87b37.js from UglifyJs
Unexpected token: name (Simple) [./node_modules/cbor/lib/simple.js:9,0][static/js/vendor.e475838be75c71f87b37.js:4155,6]
Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@1.0.0 build: `node build/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/xxx/.npm/_logs/2017-10-27T07_45_42_739Z-debug.log
cbor 包导致的错误
解决方式 :
在 webpack.base.conf.js 中找到 rules 修改 test: /\.js$/ 内容如下
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test'), resolve('node_modules/cbor')]
},