vue-cli解决IE浏览器sockjs-client错误

2,466 阅读1分钟

问题描述

用vue-cli3创建一个正常的项目,然后用浏览器访问

vue create hello-world

SCRIPT1002: 语法错误

image.png

点开报错位置

/***/ "./node_modules/sockjs-client/dist/sockjs.js":
/*!***************************************************!*\
  !*** ./node_modules/sockjs-client/dist/sockjs.js ***!
  \***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

image.png

网络解决方案

此方案根本行不通,也不知道是谁测试出来的,本人亲测完全解决不了实际问题

image.png

正确解决

降低sockjs-client的版本,他依赖描述在package-lock.json在里面,如果有这种情况出现,你的版本可能在我下方给出这个版本之上

npm i sockjs-client@1.5.1 -D

更新版本完成后在,重新编译项目

即可解决