Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10.x line cannot resolve transitive dependencies correctly #2939

Closed
2 of 4 tasks
jsumners-nr opened this issue Mar 3, 2025 · 1 comment
Closed
2 of 4 tasks

10.x line cannot resolve transitive dependencies correctly #2939

jsumners-nr opened this issue Mar 3, 2025 · 1 comment

Comments

@jsumners-nr
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I think this might be similar to #2937, but I am not sure. See reproduction for details.

Minimum reproduction code

https://example.com

Steps to reproduce

Using the following:

run.sh:

#!/bin/bash

cli="@nestjs/cli@${1:-latest}"

maints=$(
cat <<'EOF'
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

export async function bootstrap(port) {
  const app = await NestFactory.create(AppModule, { logger: false });
  await app.listen(port);
  return app
}
EOF
)

appts=$(
cat <<'EOF'
import { Controller, Get, Req } from '@nestjs/common';
import { AppService } from './app.service';
import { Request } from 'express'

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  getHello(@Req() request: Request): string {
    if (request?.query?.please_error === 'yes') {
      throw new Error('erroring out, as requested')
    }
    return this.appService.getHello();
  }
}
EOF
)

echo ${maints} > main.ts
echo ${appts} > app.controller.ts

rm -rf test-app 2>/dev/null
npx ${cli} new --package-manager npm --skip-git test-app
cd test-app
npx ${cli} build

Run ./run.sh 10 and we'll get:

▹▹▹▸▹ Installation in progress... ☕
Failed to execute command: npm install --silent
✖ Installation in progress... ☕
🙀  Packages installation failed!
In case you don't see any errors above, consider manually running the failed command npm install to see more details on why it errored out.

                          Thanks for installing Nest 🙏
                 Please consider donating to our open collective
                        to help us maintain this package.


               🍷  Donate: https://opencollective.com/nest

src/app.controller.ts:1:33 - error TS2307: Cannot find module '@nestjs/common' or its corresponding type declarations.

1 import { Controller, Get } from '@nestjs/common';
                                  ~~~~~~~~~~~~~~~~
src/app.module.ts:1:24 - error TS2307: Cannot find module '@nestjs/common' or its corresponding type declarations.

1 import { Module } from '@nestjs/common';
                         ~~~~~~~~~~~~~~~~
src/app.service.ts:1:28 - error TS2307: Cannot find module '@nestjs/common' or its corresponding type declarations.

1 import { Injectable } from '@nestjs/common';
                             ~~~~~~~~~~~~~~~~
src/main.ts:1:29 - error TS2307: Cannot find module '@nestjs/core' or its corresponding type declarations.

1 import { NestFactory } from '@nestjs/core';
                              ~~~~~~~~~~~~~~
src/main.ts:6:20 - error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

6   await app.listen(process.env.PORT ?? 3000);
                     ~~~~~~~

Found 5 error(s).

If we navigate into the test-app directory and run npm install --verbose we'll get:

npm error While resolving: [email protected]
npm error Found: [email protected]
npm error node_modules/typescript
npm error   dev typescript@"^5.1.3" from the root project
npm error   peer typescript@">=4.8.2" from @nestjs/[email protected]
npm error   node_modules/@nestjs/schematics
npm error     dev @nestjs/schematics@"^10.0.0" from the root project
npm error     @nestjs/schematics@"^10.0.1" from @nestjs/[email protected]
npm error     node_modules/@nestjs/cli
npm error       dev @nestjs/cli@"^10.0.0" from the root project
npm error
npm error Could not resolve dependency:
npm error dev @typescript-eslint/eslint-plugin@"^8.0.0" from the root project
npm error
npm error Conflicting peer dependency: [email protected]
npm error node_modules/typescript
npm error   peer typescript@">=4.8.4 <5.8.0" from @typescript-eslint/[email protected]
npm error   node_modules/@typescript-eslint/eslint-plugin
npm error     dev @typescript-eslint/eslint-plugin@"^8.0.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.

Expected behavior

npm install in a bootstrapped directory works without failure.

Package version

10.x

NestJS version

No response

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@kamilmysliwiec
Copy link
Member

Just use the latest version of the CLI (v11)

If you really need to use v10, run npm i --legacy-peer-deps as there seems to be a minor (irrelevant) peer dep versions conflict (caused by @typescript-eslint/eslint-plugin). This isn't related to NestJS

@nestjs nestjs locked and limited conversation to collaborators Mar 4, 2025
@nestjs nestjs locked and limited conversation to collaborators Mar 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants