Typescript errors following drizzle-kit quick start
Files and errors in comments
I'm attempting to follow the drizzle-kit quick start. I am encountering 2 issues. When attempting to run
index.ts
with pnpm tsc src/index.ts
I get typescript errors from inside the drizzle-orm library. When I attempt to run the resulting src/index.js
file with node src/index.js
it fails with errors.2 Replies
Errors
Error from running
Error from running
Files
package.json
src/index.ts
src/index.js
pnpm tsc src/index.ts
...
Found 23 errors in 12 files.
Errors Files
2 src/index.ts:3
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/mysql-core/db.d.ts:1
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/mysql-core/query-builders/delete.d.ts:30
7 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/mysql-core/query-builders/select.d.ts:66
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/mysql-core/query-builders/select.types.d.ts:130
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:32
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/pg-core/query-builders/select.d.ts:205
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/sqlite-core/columns/blob.d.ts:2
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/sqlite-core/query-builders/query.d.ts:25
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/sqlite-core/query-builders/raw.d.ts:11
5 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/sqlite-core/query-builders/select.d.ts:69
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.d.ts:122
...
Found 23 errors in 12 files.
Errors Files
2 src/index.ts:3
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/mysql-core/db.d.ts:1
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/mysql-core/query-builders/delete.d.ts:30
7 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/mysql-core/query-builders/select.d.ts:66
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/mysql-core/query-builders/select.types.d.ts:130
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:32
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/pg-core/query-builders/select.d.ts:205
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/sqlite-core/columns/blob.d.ts:2
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/sqlite-core/query-builders/query.d.ts:25
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/sqlite-core/query-builders/raw.d.ts:11
5 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/sqlite-core/query-builders/select.d.ts:69
1 ../../node_modules/.pnpm/drizzle-orm@0.29.0_postgres@3.4.3/node_modules/drizzle-orm/sqlite-core/query-builders/select.types.d.ts:122
node src/index.js
on resulting file from tsc
/home/shot/Develop/sky-hustlers/v2/heavens-jigsaw/apps/db/src/index.js:7
var sql = (0, postgres_1.default)(connectionString, { max: 1 });
^
TypeError: (0 , postgres_1.default) is not a function
at Object.<anonymous> (/home/shot/Develop/sky-hustlers/v2/heavens-jigsaw/apps/db/src/index.js:7:34)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49
Node.js v21.2.0
/home/shot/Develop/sky-hustlers/v2/heavens-jigsaw/apps/db/src/index.js:7
var sql = (0, postgres_1.default)(connectionString, { max: 1 });
^
TypeError: (0 , postgres_1.default) is not a function
at Object.<anonymous> (/home/shot/Develop/sky-hustlers/v2/heavens-jigsaw/apps/db/src/index.js:7:34)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49
Node.js v21.2.0
{
"name": "db",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"generate": "drizzle-kit generate:pg"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"drizzle-kit": "^0.20.4",
"typescript": "^5.3.2"
},
"dependencies": {
"drizzle-orm": "^0.29.0",
"postgres": "^3.4.3"
}
}
{
"name": "db",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"generate": "drizzle-kit generate:pg"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"drizzle-kit": "^0.20.4",
"typescript": "^5.3.2"
},
"dependencies": {
"drizzle-orm": "^0.29.0",
"postgres": "^3.4.3"
}
}
import { drizzle } from "drizzle-orm/postgres-js";
import { migrate } from "drizzle-orm/postgres-js/migrator";
import postgres from "postgres";
const connectionString = "postgresql://postgres:example@localhost/db";
const sql = postgres(connectionString, { max: 1 });
const db = drizzle(sql);
await migrate(db, { migrationsFolder: "drizzle" });
import { drizzle } from "drizzle-orm/postgres-js";
import { migrate } from "drizzle-orm/postgres-js/migrator";
import postgres from "postgres";
const connectionString = "postgresql://postgres:example@localhost/db";
const sql = postgres(connectionString, { max: 1 });
const db = drizzle(sql);
await migrate(db, { migrationsFolder: "drizzle" });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var postgres_js_1 = require("drizzle-orm/postgres-js");
var migrator_1 = require("drizzle-orm/postgres-js/migrator");
var postgres_1 = require("postgres");
var connectionString = "postgresql://postgres:example@localhost/db";
var sql = (0, postgres_1.default)(connectionString, { max: 1 });
var db = (0, postgres_js_1.drizzle)(sql);
await (0, migrator_1.migrate)(db, { migrationsFolder: "drizzle" });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var postgres_js_1 = require("drizzle-orm/postgres-js");
var migrator_1 = require("drizzle-orm/postgres-js/migrator");
var postgres_1 = require("postgres");
var connectionString = "postgresql://postgres:example@localhost/db";
var sql = (0, postgres_1.default)(connectionString, { max: 1 });
var db = (0, postgres_js_1.drizzle)(sql);
await (0, migrator_1.migrate)(db, { migrationsFolder: "drizzle" });
Hi @shot were you able to solve the issue?