ERROR in static/js/vendor.3f874bf7dde9e4503ffb.js from UglifyJs
Unexpected character '`' [./node_modules/_directive-photoswipe@0.0.2@directive-photoswipe/src/index.js:14,0][static/js/vendor.3f874bf7dde9e4503ffb.js:37495,17]
Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pingan@1.0.0 build: `node build/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pingan@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! C:\Users\z9764\AppData\Roaming\npm-cache\_logs\2018-07-10T09_29_20_595Z-debug.log
### 问题出现的环境背景及自己尝试过哪些方法
需求:在移动端,实现图片查看,功能:可以放大,缩小
背景:当时在cnpm中找到directive-photoswipe,依照文档上的说明来操作的(附directive-photoswipe地址:https://npm.taobao.org/package/directive-photoswipe)
尝试过的方法:安装babel-es2015之类的包 ,更改项目的配置等,我还联系了插件的作者,
作者的回答:我在本地测试 能正确打包 你尝试更新directive-photoswipe到0.0.3再试试.
但最终的结果让人很无奈,还是报错.
相信大家在做移动端项目时会遇到关于图片查看的功能,我把这个问题提出来希望大家帮忙一起解决这个问题,可以帮到更多的人
Unexpected character '`' ??
是不是不支持es6....
是的,不支持es6中的模板字符串,我把代码改成es5中的拼接字符串之后还是不行,随后报出两处错误
1.ERROR in static/js/vendor.b65ad78ec483e9113365.js from UglifyJs
Unexpected token: punc (() [./node_modules/_directive-photoswipe@0.0.2@directive-photoswipe/src/index.js:53,0][static/js/vendor.b65ad78ec483e9113365.js:37167,10]
2.
Failed to compile with 1 errors 11:01:29
error in ./node_modules/_directive-photoswipe@0.0.2@directive-photoswipe/src/index.js
Module parse failed: Unterminated string constant (47:4)
You may need an appropriate loader to handle this file type.
| '</div>'+
| '</div>'+
| '</div>`
|
| window.document.body.appendChild(el)
@ ./src/main.js 13:0-55
@ multi ./node_modules/_webpack-dev-server@2.11.2@webpack-dev-server/client?http://localhost:3000 webpack/hot/dev-server ./src/main.js