RobinBlomberg / kysely-codegen

Generate Kysely type definitions from your database.
MIT License
807 stars 73 forks source link

CLI throwing error: "env: node\r: No such file or director" #17

Closed Gr33nLight closed 2 years ago

Gr33nLight commented 2 years ago

Hello I installed the following dependencies in a project: yarn add -D kysely-codegen yarn add -D kysely pg I have the .env file in the root of the directory, still, when i run the command yarn run kysely-codegen I get the error: env: node\r: No such file or directory error Command failed with exit code 127.

RobinBlomberg commented 2 years ago

Try yarn add -D kysely-codegen@^0.5.2 and see if it helps.

I switched the TSConfig line endings to Unix style (LF), which might fix it, per this issue:

https://github.com/yarnpkg/yarn/issues/8106

Gr33nLight commented 2 years ago

Thanks! that fixed the issue. I got another error after updating, I'm running node v14.18.2 btw. To verify I commented the lines that use the performance module in the generator.js file and the file db.d.ts was generated suuccessfully, but I thought I'd let you know about this error as well so you could investigate :) Loaded environment variables from .env file. • No dialect specified. Assuming 'postgres'. (node:30527) UnhandledPromiseRejectionWarning: ReferenceError: performance is not defined at Generator.generate (/Users/gr33n/Documents/Dev/JS/ewi-frontend/node_modules/kysely-codegen/dist/generator.js:24:27) at Cli._Cli_generate (/Users/gr33n/Documents/Dev/JS/ewi-frontend/node_modules/kysely-codegen/dist/cli.js:68:21) at Cli.run (/Users/gr33n/Documents/Dev/JS/ewi-frontend/node_modules/kysely-codegen/dist/cli.js:41:80) at Object.<anonymous> (/Users/gr33n/Documents/Dev/JS/ewi-frontend/node_modules/kysely-codegen/dist/bin/index.js:5:22) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) at internal/main/run_main_module.js:17:47 (Usenode --trace-warnings ...to show where the warning was created) (node:30527) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) (node:30527) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

RobinBlomberg commented 2 years ago

Glad to hear that it fixed it!

Node.js LTS (long term support) version is 16.17.0 now, and while I think I'll avoid supporting legacy versions, I think import { performance } from 'perf_hooks' is an easy enough fix. I'll jump on it.

RobinBlomberg commented 2 years ago

Fixed in kysely-codegen@^0.5.3!