尝试在Node.js项目中使用npm安装Axios时出错

llycmphe  于 2023-02-04  发布在  iOS
关注(0)|答案(1)|浏览(229)

我尝试在个人项目中安装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?

bf1o4zei

bf1o4zei1#

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

相关问题