feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
14.97k stars 744 forks source link

Could not resolve dependency: peer knex@"^2.5.1" from @feathersjs/knex@5.0.10 #3305

Closed K4CZP3R closed 9 months ago

K4CZP3R commented 9 months ago

Steps to reproduce

  1. npm create feathers@latest feathers-chat
  2. Fill in:
    Need to install the following packages:
    create-feathers@5.0.10
    Ok to proceed? (y) y
    ? Do you want to use JavaScript or TypeScript? TypeScript
    ? Write a short description Timeular payday calculator
    ? Which HTTP framework do you want to use? KoaJS (recommended)
    ? What APIs do you want to offer? HTTP (REST), Real-time
    ? Which package manager are you using? npm
    ? Generate end-to-end typed client? Can be used with React, Angular, Vue, React Native, Node.js etc. Yes
    ? What is your preferred schema (model) definition format? Schemas allow to type, validate, secure and populate your data and configuration TypeBox (recommended)
    ? Which database are you connecting to? Databases can be added at any time PostgreSQL
    ? Enter your database connection string postgres://username:password@yes.eu-central-1.aws.neon.tech/neondb

Expected behavior

Project should be initialized and packages should be downloaded.

Actual behavior

After entering details about the database, setup process crashes with the following error:

...
    Wrote file .prettierrc
    Wrote file readme.md
    Wrote file src/services/index.ts
    Wrote file tsconfig.json
    Wrote file src/validators.ts
    Wrote file src/postgresql.ts
    Wrote file knexfile.ts
    Updated src/app.ts
    Running npm install --save
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: feathers-payday@0.0.0
npm ERR! Found: knex@3.0.1
npm ERR! node_modules/knex
npm ERR!   knex@"3.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer knex@"^2.5.1" from @feathersjs/knex@5.0.10
npm ERR! node_modules/@feathersjs/knex
npm ERR!   @feathersjs/knex@"^5.0.10" 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! /Users/kacperserewis/.npm/_logs/2023-10-06T13_54_55_400Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /Users/a/.npm/_logs/2023-10-06T13_54_55_400Z-debug-0.log

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working):

NodeJS version: v20.5.1

Operating System: MacOS Sonoma 14.1

Browser Version: -

React Native Version: -

Module Loader: -

K4CZP3R commented 9 months ago

Running it with pnpm instead of npm shows following warning:

 WARN  Issues with peer dependencies found
.
└─┬ @feathersjs/knex 5.0.10
  └── ✕ unmet peer knex@^2.5.1: found 3.0.1
AshotN commented 9 months ago

Am able to reproduce this issue, does not happen when the package manager selected is yarn. But npm causes an issue

daffl commented 9 months ago

I thought this was the same problem that was fixed with https://github.com/feathersjs/feathers/pull/3294 but it's actually because knex is missing in the generator dependencies at https://github.com/feathersjs/feathers/blob/9689a9570037a62f1c735f6c13302f583d01f351/packages/generators/package.json so it'll always install the latest version