npm run start:dev
> [email protected] 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
Also when trying to run npm install I am getting:
[root@ip-172-31-82-139 server]# npm install
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: @nestjs/[email protected]
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/[email protected]
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: [email protected]
npm WARN Found: @nestjs/[email protected]
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/[email protected]
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: [email protected]
npm WARN Found: @nestjs/[email protected]
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/[email protected]
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: [email protected]
npm WARN Found: @nestjs/[email protected]
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/[email protected]
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: [email protected]
npm WARN Found: @nestjs/[email protected]
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/[email protected]
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: [email protected]
npm ERR! Found: @nestjs/[email protected]
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/[email protected]
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/[email protected]
npm ERR! node_modules/@nestjs/platform-express
npm ERR! peerOptional @nestjs/platform-express@"^10.0.0" from @nestjs/[email protected]
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
This is how the package.json looks like:
{
"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"
}
}
}
What am I doing wrong?
2
Answers
Try adding the param
--legacy-peer-deps
tonpm install
.Does the install work without errors now?
More info on
--legacy-peer-deps
.I went the full fix and removed the @nestjs packages from package.json, then reinstalled them with
npm i @nestjs/common @nestjs/core @nestjs/platform-express --save
.My package.json looked like so:
If you’ve already ran an
npm install
and have a node_modules folder, delete that folder and the package-lock.json file too, prior to running the above install command.