NodeJS 尝试在EC2计算机上运行Nest.js时出错

hgtggwj0  于 2023-06-22  发布在  Node.js
关注(0)|答案(1)|浏览(175)

npm run start:dev

> server@0.0.1 start:dev
> cross-env NODE_ENV=development nest start --watch

node:events:489
      throw er; // Unhandled 'error' event
      ^

Error: spawn nest ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:285:19)
    at onErrorNT (node:internal/child_process:483:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)
    at onErrorNT (node:internal/child_process:483:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn nest',
  path: 'nest',
  spawnargs: [ 'start', '--watch' ]
}

Node.js v20.3.0

另外,当尝试运行npm install时,我得到:

[root@ip-172-31-82-139 server]# npm install
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: server@0.0.1
npm WARN Found: @nestjs/common@9.2.1
npm WARN node_modules/@nestjs/common
npm WARN   @nestjs/common@"^10.0.1" from the root project
npm WARN   13 more (@liaoliaots/nestjs-redis, @nestjs/config, ...)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer @nestjs/common@"^9.0.0" from @liaoliaots/nestjs-redis@9.0.5
npm WARN node_modules/@liaoliaots/nestjs-redis
npm WARN   @liaoliaots/nestjs-redis@"^9.0.5" from the root project
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: server@0.0.1
npm WARN Found: @nestjs/common@9.2.1
npm WARN node_modules/@nestjs/common
npm WARN   @nestjs/common@"^10.0.1" from the root project
npm WARN   13 more (@liaoliaots/nestjs-redis, @nestjs/config, ...)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer @nestjs/common@"^9.0.0" from @nestjs/core@9.2.1
npm WARN node_modules/@nestjs/core
npm WARN   @nestjs/core@"^10.0.1" from the root project
npm WARN   7 more (@liaoliaots/nestjs-redis, @nestjs/mongoose, ...)
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: server@0.0.1
npm WARN Found: @nestjs/common@9.2.1
npm WARN node_modules/@nestjs/common
npm WARN   @nestjs/common@"^10.0.1" from the root project
npm WARN   13 more (@liaoliaots/nestjs-redis, @nestjs/config, ...)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer @nestjs/common@"^9.0.0" from @nestjs/core@9.2.1
npm WARN node_modules/@nestjs/core
npm WARN   @nestjs/core@"^10.0.1" from the root project
npm WARN   7 more (@liaoliaots/nestjs-redis, @nestjs/mongoose, ...)
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: server@0.0.1
npm WARN Found: @nestjs/common@9.2.1
npm WARN node_modules/@nestjs/common
npm WARN   @nestjs/common@"^10.0.1" from the root project
npm WARN   13 more (@liaoliaots/nestjs-redis, @nestjs/config, ...)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer @nestjs/common@"^9.0.0" from @nestjs/platform-express@9.2.1
npm WARN node_modules/@nestjs/platform-express
npm WARN   @nestjs/platform-express@"^10.0.1" from the root project
npm WARN   2 more (@nestjs/core, @nestjs/testing)
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: server@0.0.1
npm WARN Found: @nestjs/common@9.2.1
npm WARN node_modules/@nestjs/common
npm WARN   @nestjs/common@"^10.0.1" from the root project
npm WARN   13 more (@liaoliaots/nestjs-redis, @nestjs/config, ...)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer @nestjs/common@"^9.0.0" from @nestjs/platform-express@9.2.1
npm WARN node_modules/@nestjs/platform-express
npm WARN   @nestjs/platform-express@"^10.0.1" from the root project
npm WARN   2 more (@nestjs/core, @nestjs/testing)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: server@0.0.1
npm ERR! Found: @nestjs/core@9.2.1
npm ERR! node_modules/@nestjs/core
npm ERR!   @nestjs/core@"^10.0.1" from the root project
npm ERR!   peer @nestjs/core@"^9.0.0" from @liaoliaots/nestjs-redis@9.0.5
npm ERR!   node_modules/@liaoliaots/nestjs-redis
npm ERR!     @liaoliaots/nestjs-redis@"^9.0.5" from the root project
npm ERR!   6 more (@nestjs/mongoose, @nestjs/platform-express, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! @nestjs/core@"^10.0.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @nestjs/platform-express@10.0.1
npm ERR! node_modules/@nestjs/platform-express
npm ERR!   peerOptional @nestjs/platform-express@"^10.0.0" from @nestjs/core@10.0.1
npm ERR!   node_modules/@nestjs/core
npm ERR!     @nestjs/core@"^10.0.1" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /root/.npm/_logs/2023-06-19T07_03_58_732Z-eresolve-report.txt

package.json如下所示:

{
  "name": "server",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "engines": {
    "npm": ">=8.0.0 <9.0.0",
    "node": ">=16.0.0 <17.0.0"
  },
  "scripts": {
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "cross-env NODE_ENV=production nest start",
    "start:dev": "cross-env NODE_ENV=development nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch --testTimeout=10000",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json",
    "prepare": "husky install",
    "migration:up": "migrate-mongo up",
    "migration:down": "migrate-mongo down"
  },
  "lint-staged": {
    "src/**/*.ts": [
      "prettier --write",
      "eslint --fix"
    ]
  },
  "dependencies": {
    "@liaoliaots/nestjs-redis": "^9.0.5",
    "@nestjs/axios": "^3.0.0",
    "@nestjs/bull": "^10.0.0",
    "@nestjs/common": "^10.0.1",
    "@nestjs/config": "^3.0.0",
    "@nestjs/core": "^10.0.1",
    "@nestjs/jwt": "^10.1.0",
    "@nestjs/mongoose": "^10.0.0",
    "@nestjs/passport": "^10.0.0",
    "@nestjs/platform-express": "^10.0.1",
    "@nestjs/schedule": "^3.0.1",
    "@nestjs/swagger": "^7.0.1",
    "@types/cache-manager": "^4.0.2",
    "@types/md5": "^2.3.2",
    "axios": "^1.4.0",
    "bull": "^4.10.4",
    "cache-manager": "^5.2.3",
    "cache-manager-redis-store": "^3.0.1",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.0",
    "cross-env": "^7.0.3",
    "crypto": "^1.0.1",
    "date-fns": "^2.30.0",
    "date-fns-tz": "^2.0.0",
    "dotenv": "^16.3.1",
    "ejs": "^3.1.9",
    "http-method-enum": "^1.0.0",
    "ioredis": "^5.3.2",
    "jsonwebtoken": "^9.0.0",
    "lodash": "^4.17.21",
    "luxon": "^3.3.0",
    "md5": "^2.3.0",
    "migrate-mongo": "^10.0.0",
    "mongoose": "^7.3.0",
    "nestjs-redis": "^1.3.3",
    "node-apple-receipt-verify": "^1.12.1",
    "otp-generator": "^4.0.1",
    "passport": "^0.6.0",
    "passport-jwt": "^4.0.1",
    "passport-local": "^1.0.0",
    "redis": "^4.6.7",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^5.0.1",
    "rxjs": "^7.8.1",
    "twilio": "^4.12.0",
    "uuid": "^9.0.0",
    "uuidv4": "^6.2.13"
  },
  "devDependencies": {
    "@babel/core": "^7.22.5",
    "@babel/preset-env": "^7.22.5",
    "@babel/preset-typescript": "^7.22.5",
    "@nestjs/cli": "^10.0.2",
    "@nestjs/schematics": "^10.0.1",
    "@nestjs/testing": "^10.0.1",
    "@types/bull": "^3.15.9",
    "@types/cron": "^2.0.1",
    "@types/express": "^4.17.17",
    "@types/jest": "^29.5.2",
    "@types/lodash": "^4.14.195",
    "@types/node": "^20.3.1",
    "@types/otp-generator": "^4.0.0",
    "@types/passport-local": "^1.0.35",
    "@types/supertest": "^2.0.12",
    "@typescript-eslint/eslint-plugin": "^5.59.11",
    "@typescript-eslint/parser": "^5.59.11",
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "^29.5.0",
    "eslint": "^8.43.0",
    "eslint-config-prettier": "^8.8.0",
    "eslint-plugin-prettier": "^4.2.1",
    "husky": "^8.0.3",
    "jest": "^29.5.0",
    "lint-staged": "^13.2.2",
    "mongodb-memory-server": "^8.13.0",
    "prettier": "^2.8.8",
    "run-script-webpack-plugin": "^0.2.0",
    "source-map-support": "^0.5.21",
    "supertest": "^6.3.3",
    "test-jest": "^1.0.1",
    "ts-jest": "^29.1.0",
    "ts-loader": "^9.4.3",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.1.3",
    "webpack": "^5.87.0",
    "webpack-node-externals": "^3.0.0"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node",
    "preset": "ts-jest",
    "transform": {
      "^.+\\.(ts|tsx)?$": "ts-jest",
      "^.+\\.(js|jsx)$": "babel-jest"
    }
  }
}

我做错了什么?

fiei3ece

fiei3ece1#

尝试将参数--legacy-peer-deps添加到npm install
现在安装工作正常吗?
关于--legacy-peer-deps的更多信息

相关问题