You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WebStorm中npm安装axios模块失败求助

WebStorm中安装axios失败问题

我在WebStorm里安装axios模块时出现错误,无法解决。相关报错截图:
报错截图1
报错截图2

未修改的package.json文件内容如下:

{
  "name": "todolist",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.8.3",
    "vue": "^2.6.14",
    "vue-router": "^3.5.1",
    "vuex": "^3.6.2"
  },
  "devDependencies": {
    "@babel/core": "^7.12.16",
    "@babel/eslint-parser": "^7.12.16",
    "@vue/cli-plugin-babel": "~5.0.0",
    "@vue/cli-plugin-eslint": "~5.0.0",
    "@vue/cli-plugin-router": "~5.0.0",
    "@vue/cli-plugin-vuex": "~5.0.0",
    "@vue/cli-service": "~5.0.0",
    "@vue/eslint-config-standard": "^6.1.0",
    "eslint": "^7.32.0",
    "eslint-plugin-import": "^2.25.3",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^5.1.0",
    "eslint-plugin-vue": "^8.0.3",
    "lint-staged": "^11.1.2",
    "sass": "^1.32.7",
    "sass-loader": "^12.0.0",
    "vue-template-compiler": "^2.6.14"
  },
  "gitHooks": {
    "pre-commit": "lint-staged"
  }
}

终端执行npm -i axios后的结果截图:
终端执行结果


解决方法

  • 修正安装命令:使用npm install axios或简写npm i axios,原命令npm -i axios格式错误,-i需搭配包名使用,正确写法为npm i axios
  • 清理npm缓存:运行npm cache clean --force,之后重新执行安装命令
  • 切换镜像源:若网络访问npm官方源不稳定,用国内镜像安装:npm install axios --registry=https://registry.npmmirror.com
  • 检查Node环境:确认WebStorm终端使用的Node.js版本与系统一致,可在WebStorm「设置-语言和框架-Node.js and NPM」中核对解释器路径

内容的提问来源于stack exchange,提问作者陈慢慢

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 10:18:19