WebStorm中npm安装axios模块失败求助
WebStorm中安装axios失败问题
我在WebStorm里安装axios模块时出现错误,无法解决。相关报错截图:

未修改的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,提问作者陈慢慢
相关产品推荐
相关产品推荐

