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

package.json generated by typeorm init has wrong version of ts-node #8820

Closed
mishagale opened this issue Mar 28, 2022 · 10 comments
Closed

package.json generated by typeorm init has wrong version of ts-node #8820

mishagale opened this issue Mar 28, 2022 · 10 comments

Comments

@mishagale
Copy link

Issue Description

It seems like typeorm init produces a package.json with ts-node version 10.4.0:

$ jq .devDependencies package.json
{
  "ts-node": "10.4.0",
  "@types/node": "^16.11.10",
  "typescript": "4.5.2"
}

However, typeorm itself has a peer-dependency for ^10.7.0:

$ jq .peerDependencies /home/michael/.nvm/versions/node/v16.14.2/lib/node_modules/typeorm/package.json
{
  "@sap/hana-client": "^2.11.14",
  "better-sqlite3": "^7.1.2",
  "hdb-pool": "^0.1.6",
  "ioredis": "^4.28.3",
  "mongodb": "^3.6.0",
  "mssql": "^6.3.1",
  "mysql2": "^2.2.5",
  "oracledb": "^5.1.0",
  "pg": "^8.5.1",
  "pg-native": "^3.0.0",
  "pg-query-stream": "^4.0.0",
  "redis": "^3.1.1",
  "sql.js": "^1.4.0",
  "sqlite3": "^5.0.2",
  "ts-node": "^10.7.0",
  "typeorm-aurora-data-api-driver": "^2.0.0"
}

Expected Behavior

running typeorm init produces a project skeleton and installs dependencies

Actual Behavior

$ typeorm init
Project created inside current directory.
Please wait, installing dependencies...
Error during project initialization:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: typeorm@0.3.4
npm ERR! Found: ts-node@10.4.0
npm ERR! node_modules/ts-node
npm ERR!   dev ts-node@"10.4.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional ts-node@"^10.7.0" from typeorm@0.3.4
npm ERR! node_modules/typeorm
npm ERR!   typeorm@"0.3.4" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: ts-node@10.7.0
npm ERR! node_modules/ts-node
npm ERR!   peerOptional ts-node@"^10.7.0" from typeorm@0.3.4
npm ERR!   node_modules/typeorm
npm ERR!     typeorm@"0.3.4" 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! See /home/michael/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/michael/.npm/_logs/2022-03-28T11_06_55_393Z-debug-0.log

Steps to Reproduce

  1. install typeorm globally with npm install -g typeorm
  2. in an empty directory, run typeorm init

Workaround

Edit the generated package.json changing

      "ts-node": "10.4.0",

to

      "ts-node": "10.7.0",

then manually run npm install

My Environment

Dependency Version
Operating System Ubuntu 20.04.4 running in WSL 2 on Windows 10
Node.js version 16.14.2
Typescript version none (didn't get as far as installing TS)
TypeORM version 0.3.4

Additional Context

Note that I'm running in WSL - I don't think that's relevant to the issue though.

Relevant Database Driver(s)

N/A

DB Type Reproducible
aurora-mysql no
aurora-postgres no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb no
mysql no
nativescript no
oracle no
postgres no
react-native no
sap no
sqlite no
sqlite-abstract no
sqljs no
sqlserver no

Are you willing to resolve this issue by submitting a Pull Request?

  • ✅ Yes, I have the time, and I know how to start.
  • ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
@mishagale
Copy link
Author

mishagale commented Mar 28, 2022

I think this line is the cause of the bug:

"ts-node": "10.4.0",

However, another fix would be to just make the peerDependency requirement less strict (unless we know that we really do need ts-node 10.7?):

"ts-node": "^10.7.0",

Maybe just use ^10 or >=10.0.0

@akindo
Copy link

akindo commented Mar 30, 2022

Can concur this is an issue. 🪲

@pleerock
Copy link
Member

Feel free to PR!

@sgshy1995
Copy link

Version rollback to 0.2.45 can solve this problem.

@MillingtonAllen
Copy link

MillingtonAllen commented Apr 3, 2022

Version rollback to 0.2.45 can solve this problem.

Thanks, this works for now.

Might be pretty obvious to most, but for anyone new to programming (my experience level one month ago), navigate to a project directory run npm install typeorm@0.2.45 --save-dev to use the old version. Then run npx typeorm init and it should work. might want to specify additional things in the init like --database db_type or similar.

@AnujSsStw
Copy link

AnujSsStw commented Apr 4, 2022

Hey, why it solved with version rollback?
and question - after rollback and getting all the file can we go back to latest version?

@pleerock
Copy link
Member

pleerock commented Apr 4, 2022

there is a (looks like a working) solution proposed by @mishagale , no need to confuse users with obviously worse solutions.

mishagale added a commit to mishagale/typeorm that referenced this issue Apr 4, 2022
The version needs to be compatible with the peerDependency version in typeorm's own package.json

Closes typeorm#8820
@AnujSsStw
Copy link

@pleerock thanks it really just looked like a working solution. After that other things start conflicting

@MillingtonAllen
Copy link

there is a (looks like a working) solution proposed by @mishagale , no need to confuse users with obviously worse solutions.

I'm guessing that how to implement said solution is obvious to you. Implementing the fix is not going to be obvious to people that are newer to react (and git). Offhand, I didn't know how to implement the proposed fix. There is value in providing a practical solution. A rollback allowed me to continue to program while waiting for the fix to go live. I agree that it's not optimal if major functionality has changed between versions, but it's better than getting stuck.

After researching it more, the practical implementation of the proposed solution is:

Assuming you're already at the point where the npx init typeorm has errored out, go to

project_folder/node_modules/typeorm/commands/InitCommand.js

change the line that reads:
"ts-node": "10.4.0",

to
"ts-node": "10.7.0",

Then navigate back to the project_folder and run npx typeorm init and it should work. Probably still want to specify additional things in the init like --database db_type or similar.

@pleerock

@pleerock
Copy link
Member

pleerock commented Apr 5, 2022

closed by 7b4bca7

@pleerock pleerock closed this as completed Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants