【问题标题】:Error trying to install Axios with npm in a Node.js project尝试在 Node.js 项目中使用 npm 安装 Axios 时出错
【发布时间】:2023-02-03 22:36:17
【问题描述】:

我正在尝试在个人项目中安装 axios 以学习 Node.js、mongoDB 和 express,但在使用 npm 安装时遇到错误。我在执行npm i --save axios 时遇到的问题是这个:

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code EPERM
npm ERR! syscall lstat
npm ERR! path F:\Laboral\Elonial\Curso Node.js\4-natours\node_modules\simple-swizzle
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, lstat 'F:\Laboral\Elonial\Curso Node.js\4-natours\node_modules\simple-swizzle'       
npm ERR!  [Error: EPERM: operation not permitted, lstat 'F:\Laboral\Elonial\Curso Node.js\4-natours\node_modules\simple-swizzle'] {  
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'lstat',
npm ERR!   path: 'F:\\Laboral\\Elonial\\Curso Node.js\\4-natours\\node_modules\\simple-swizzle'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\djime\AppData\Local\npm-cache\_logs\2023-02-03T12_21_26_556Z-debug-0.log

我已经尝试通过 cmd 将其安装到具有管理员权限的项目中,但出现了同样的错误。我的package.json 现在正在关注这个:

{
  "name": "natours",
  "version": "1.0.0",
  "description": "Project created by NukeSkull in order to learn node.js, express and mongoDB",
  "main": "app.js",
  "scripts": {
    "start": "nodemon server.js",
    "start:prod": "SET NODE_ENV=production&&nodemon server.js",
    "debug": "ndb server.js",
    "watch:js": "parcel watch ./public/js/index.js --out-dir ./public/js --out-file bundle.js",
    "build:js": "parcel watch ./public/js/index.js --out-dir ./public/js --out-file bundle.js"
  },
  "author": "NukeSkull",
  "license": "ISC",
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "cookie-parser": "^1.4.6",
    "dotenv": "^16.0.1",
    "express": "^4.18.1",
    "express-mongo-sanitize": "^2.2.0",
    "express-rate-limit": "^6.6.0",
    "helmet": "^3.23.3",
    "hpp": "^0.2.3",
    "jsonwebtoken": "^8.5.1",
    "mapbox-gl": "^2.12.0",
    "mongoose": "^5.13.15",
    "morgan": "^1.10.0",
    "nodemailer": "^6.7.8",
    "nodemon": "^2.0.19",
    "pug": "^3.0.2",
    "slugify": "^1.6.5",
    "validator": "^13.7.0",
    "xss-clean": "^0.1.1"
  },
  "devDependencies": {
    "eslint": "^8.22.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-jsx-a11y": "^6.6.1",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-react": "^7.30.1",
    "parcel-bundler": "^1.12.5",
    "prettier": "^2.7.1"
  },
  "engines": {
    "node": ">=10.0.0"
  }
}

我该如何解决这个错误,以便我可以安装 axios?

【问题讨论】:

标签: npm axios npm-install


【解决方案1】:

发现我的错误,不知何故 Windows 防病毒软件阻止我安装它,禁用它允许我安装 axios。感谢@Samball 的回答

【讨论】:

    猜你喜欢
    • 2011-12-04
    • 2020-10-20
    • 2018-01-25
    • 2020-09-19
    • 1970-01-01
    • 2021-11-06
    • 1970-01-01
    • 1970-01-01
    • 2022-08-05
    相关资源
    最近更新 更多