npm 安装 Echarts 失败
使用 npm 安装 Echarts :
npm install echarts --save
安装后报错,原因在于使用的 Vue 版本和 Echarts 版本不兼容。我使用的 Vue 版本号为 @2.6.11,而 Echarts 版本号为 @5.0.1。进入 package.json 查看版本号。
"dependencies": { "axios": "^0.21.1", "core-js": "^3.6.5", "echarts": "^5.0.1", "element-ui": "^2.14.1", "vue": "^2.6.11", "vue-router": "^3.0.7", "vuex": "^3.4.0" },
因此,需要退回 Echarts @4.9.0 。
npm unistall echarts // 卸载 Echarts
npm install echarts@4.9.0
安装并没有报错,安装成功。
- echarts@4.9.0
added 2 packages and audited 1237 packages in 38.894s60 packages are looking for funding
runnpm fund
for detailsfound 0 vulnerabilities