代码之家  ›  专栏  ›  技术社区  ›  ikianm

为什么npm install在NestJS/ubuntu中不能正常工作

  •  0
  • ikianm  · 技术社区  · 11 月前

    我当时在做一个NestJS项目,最近我从windows转到了Ubuntu,有一次我在linux上从github克隆了这个项目 npm install 命令不起作用,出现以下错误:

    Precision-5530:~/projects/warehousing$ npm install
    npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
    npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
    npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
    npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
    npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
    npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
    npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
    npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
    npm warn deprecated [email protected]: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net
    
    > [email protected] postinstall
    > patch-package
    
    sh: 1: patch-package: not found
    npm error code 127
    npm error path /home/ikianm/projects/warehousing
    npm error command failed
    npm error command sh -c patch-package
    
    npm error A complete log of this run can be found in: /home/ikianm/.npm/_logs/2024-07-16T17_49_41_064Z-debug-0.log
    

    我的窗户上一切正常,但现在不起作用了。 我安装了NodeJS版本20.15.1和npm版本10.7.0。 以下是package.json的内容,以防万一:

    {
      "name": "warehousing",
      "version": "0.0.1",
      "description": "",
      "author": "",
      "private": true,
      "license": "UNLICENSED",
      "scripts": {
        "postinstall": "patch-package",
        "build": "nest build",
        "format": "prettier --write \"src//*.ts\" \"test//*.ts\"",
        "start": "cross-env NODE_ENV=development nest start",
        "start:dev": "cross-env NODE_ENV=development nest start --watch",
        "start:debug": "cross-env NODE_ENV=development nest start --debug --watch",
        "start:prod": "cross-env NODE_ENV=production node dist/main",
        "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
        "test": "cross-env NODE_ENV=test jest",
        "test:watch": "cross-env NODE_ENV=test jest --watch",
        "test:cov": "cross-env NODE_ENV=test jest --coverage",
        "test:debug": "cross-env NODE_ENV=test node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
        "test:e2e": "cross-env NODE_ENV=test jest --config ./test/jest-e2e.json --logHeapUsage --runInBand --detectOpenHandles  --verbose --watchAll"
      },
      "dependencies": {
        "@nestjs/common": "^10.0.0",
        "@nestjs/config": "^3.2.2",
        "@nestjs/core": "^10.0.0",
        "@nestjs/mapped-types": "^2.0.5",
        "@nestjs/platform-express": "^10.0.0",
        "@nestjs/typeorm": "^10.0.2",
        "axios": "^1.7.2",
        "class-transformer": "^0.5.1",
        "class-validator": "^0.14.1",
        "cross-env": "^7.0.3",
        "jsonwebtoken": "^9.0.2",
        "mysql2": "^3.10.0",
        "nestjs-request-context": "^3.0.0",
        "qs": "^6.12.1",
        "reflect-metadata": "^0.2.0",
        "rxjs": "^7.8.1",
        "typeorm": "^0.3.20"
      },
      "devDependencies": {
        "@commitlint/cli": "^19.3.0",
        "@commitlint/config-conventional": "^19.2.2",
        "@nestjs/cli": "^10.0.0",
        "@nestjs/schematics": "^10.0.0",
        "@nestjs/swagger": "^7.3.1",
        "@nestjs/testing": "^10.0.0",
        "@types/express": "^4.17.17",
        "@types/jest": "^29.5.2",
        "@types/node": "^20.3.1",
        "@types/supertest": "^6.0.0",
        "@typescript-eslint/eslint-plugin": "^6.0.0",
        "@typescript-eslint/parser": "^6.0.0",
        "eslint": "^8.42.0",
        "eslint-config-prettier": "^9.0.0",
        "eslint-plugin-prettier": "^5.0.0",
        "husky": "^9.0.11",
        "jest": "^29.5.0",
        "prettier": "^3.0.0",
        "source-map-support": "^0.5.21",
        "supertest": "^6.3.3",
        "ts-jest": "^29.1.0",
        "ts-loader": "^9.4.3",
        "ts-node": "^10.9.1",
        "tsconfig-paths": "^4.2.0",
        "typescript": "^5.1.3"
      },
      "jest": {
        "moduleFileExtensions": [
          "js",
          "json",
          "ts"
        ],
        "rootDir": "src",
        "testRegex": ".*\\.spec\\.ts$",
        "transform": {
          "^.+\\.(t|j)s$": "ts-jest"
        },
        "collectCoverageFrom": [
          "**/*.(t|j)s"
        ],
        "coverageDirectory": "../coverage",
        "testEnvironment": "node"
      }
    }
    
    1 回复  |  直到 11 月前
        1
  •  0
  •   Tauseef Razaq    11 月前

    尝试使用以下命令将补丁包作为开发依赖项安装 npm install patch-package --save-dev 命令,然后重新运行 npm install