vue项目打包时出错

npm run build后出现以下信息:

D:\vue\my>npm run build

> my@1.0.0 build D:\vue\my
> node build/build.js

- building for production...D:\vue\my\node_modules\uglifyjs-webpack-plugin\dist\
index.js:272
          return new Error(`${file} from UglifyJs\n${err.message} [${requestShor
tener.shorten(original.source)}:${original.line},${original.column}][${file}:${e
rr.line},${err.col}]`);

      ^

TypeError: requestShortener.shorten is not a function
    at Function.buildError (D:\vue\my\node_modules\uglifyjs-webpack-plugin\dist\
index.js:272:87)
    at D:\vue\my\node_modules\uglifyjs-webpack-plugin\dist\index.js:206:56
    at Array.forEach (native)
    at D:\vue\my\node_modules\uglifyjs-webpack-plugin\dist\index.js:189:21
    at step (D:\vue\my\node_modules\uglifyjs-webpack-plugin\dist\uglify\index.js
:90:11)
    at done (D:\vue\my\node_modules\uglifyjs-webpack-plugin\dist\uglify\index.js
:99:22)
    at D:\vue\my\node_modules\uglifyjs-webpack-plugin\dist\uglify\index.js:105:1
5
    at D:\vue\my\node_modules\worker-farm\lib\farm.js:191:19
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.11.4
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! my@1.0.0 build: `node build/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my@1.0.0 build script 'node build/build.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the my package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build/build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs my
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls my
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\vue\my\npm-debug.log

package.json

{
  "name": "my",
  "version": "1.0.0",
  "description": "A Vue.js project",
  "author": "",
  "private": true,
  "scripts": {
    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
    "start": "npm run dev",
    "e2e": "node test/e2e/runner.js",
    "test": "npm run e2e",
    "build": "node build/build.js"
  },
  "dependencies": {
    "better-scroll": "^1.7.2",
    "mint-ui": "^2.2.13",
    "vue": "^2.5.2",
    "vue-clipboard2": "0.0.8",
    "vue-router": "^3.0.1",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "autoprefixer": "^7.1.2",
    "babel-core": "^6.22.1",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-loader": "^7.1.1",
    "babel-plugin-syntax-jsx": "^6.18.0",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-plugin-transform-vue-jsx": "^3.5.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-stage-2": "^6.22.0",
    "babel-register": "^6.22.0",
    "chalk": "^2.0.1",
    "chromedriver": "^2.27.2",
    "copy-webpack-plugin": "^4.0.1",
    "cross-spawn": "^5.0.1",
    "css-loader": "^0.28.0",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^1.1.4",
    "friendly-errors-webpack-plugin": "^1.6.1",
    "html-webpack-plugin": "^2.30.1",
    "nightwatch": "^0.9.12",
    "node-notifier": "^5.1.2",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "ora": "^1.2.0",
    "portfinder": "^1.0.13",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.0.8",
    "rimraf": "^2.6.0",
    "selenium-server": "^3.0.1",
    "semver": "^5.3.0",
    "shelljs": "^0.7.6",
    "uglifyjs-webpack-plugin": "^1.1.1",
    "url-loader": "^0.5.8",
    "vue-loader": "^13.3.0",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.5.2",
    "webpack": "^3.6.0",
    "webpack-bundle-analyzer": "^2.9.0",
    "webpack-dev-server": "^2.9.1",
    "webpack-merge": "^4.1.0"
  },
  "engines": {
    "node": ">= 4.0.0",
    "npm": ">= 3.0.0"
  }
}

在一些地方使用了ES6语法,会是这个问题吗?

回答:

这种是依赖包内部报错,一般不是你的问题

npm install uglifyjs-webpack-plugin@0.4.6 -D 把版本锁死试试

暂无评论

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注