Replies: 1 comment
-
strange no answer |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
i am facing issue, when i build project, path gets added in database config file below is error
Edward@Edward-PC MINGW64 ~/Documents/Project_server/server (main)
$ npm start
node:internal/modules/esm/resolve:313
return new ERR_PACKAGE_PATH_NOT_EXPORTED(
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './node-postgres/index.js' is not defined by "exports" in C:\Users\Edward\Documents\Project_server\server\node_modules\drizzle-orm\package.json imported from C:\Users\Edward\Documents\Project_server\server\dist\config\postgres.js
at exportsNotFound (node:internal/modules/esm/resolve:313:10)
at packageExportsResolve (node:internal/modules/esm/resolve:660:9)
at packageResolve (node:internal/modules/esm/resolve:773:12)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:208:49) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Node.js v24.4.1
Edward@Edward-PC MINGW64 ~/Documents/Project_server/server (main)----------original file ----------- import 'dotenv/config';
import { Pool } from 'pg';
import { drizzle } from 'drizzle-orm/node-postgres';
import * as schema from '../drizzle/schema';
import { getEnv } from '../utils/env';
import { logger } from '../utils/logger';
const MAX_RETRIES = 5;
const RETRY_DELAY_MS = 3000;
const pool = new Pool({
connectionString: getEnv('DATABASE_URL'),
max: 10,
});
export const db = drizzle(pool, { schema });
/**
*/
function sleep(ms: number): Promise {
return new Promise(resolve => setTimeout(resolve, ms));
}
/**
Attempts to connect to PostgreSQL with retry logic.
*/
export async function connectPostgresWithRetry(attempt = 1): Promise {
try {
const client = await pool.connect();
client.release();
logger.info('✅ Connected to PostgreSQL via Drizzle');
} catch (error: unknown) {
logger.error(
❌ Failed to connect to PostgreSQL (Attempt ${attempt}):
, error);if (attempt < MAX_RETRIES) {
logger.info(
🔁 Retrying in ${RETRY_DELAY_MS / 1000} seconds...
);await sleep(RETRY_DELAY_MS);
return connectPostgresWithRetry(attempt + 1);
}
logger.fatal('💥 Max retries reached. Could not connect to PostgreSQL.');
await shutdownGracefully(1);
}
}
/**
*/
async function shutdownGracefully(exitCode: number): Promise {
try {
await pool.end(); // closes all connections
logger.info('🧹 PostgreSQL pool closed.');
} catch (closeError) {
logger.warn('
} finally {
process.exit(exitCode);
}
}
export async function closePostgres() {
await pool.end();
}------------------------------
in build response
import 'dotenv/config.js';
import { Pool } from 'pg';
import { drizzle } from 'drizzle-orm/node-postgres/index.js';
import * as schema from '../drizzle/schema.js';
import { getEnv } from '../utils/env.js';
import { logger } from '../utils/logger.js';
const MAX_RETRIES = 5;
const RETRY_DELAY_MS = 3000;
const pool = new Pool({
connectionString: getEnv('DATABASE_URL'),
max: 10,
});
export --------------------
tsconfig file {
"compilerOptions": {
"target": "ES2024", // Target ECMAScript 2024 features
"module": "ESNext", // Use ES module syntax
"moduleResolution": "Node", // Resolve modules like Node.js
"lib": ["ES2024"], // Include ECMAScript 2024 library features
"strict": true, // Enable all strict type-checking options
"esModuleInterop": true, // Enable default imports for CommonJS modules
"skipLibCheck": true, // Skip type checking of declaration files
"forceConsistentCasingInFileNames": true, // Enforce consistent file naming
"allowJs": true, // Allow JavaScript files in the project
"checkJs": true, // Enable type checking for JavaScript files
"jsx": "react", // Support .tsx files for React syntax (optional)
"declaration": false, // Do not generate declaration files
"declarationMap": false, // Do not generate declaration maps
"outDir": "./dist", // Output compiled files into the 'dist' directory
"rootDir": "./src", // Input source files will be in the 'src' directory
"baseUrl": ".", // Set base directory for module resolution
"resolveJsonModule": true, // Allows importing JSON files as modules
"experimentalDecorators": true, // Enable experimental support for decorators
"skipDefaultLibCheck": true, // Skip checking the default lib.d.ts files
"paths": {
"@controllers/": ["src/controllers/"],
"@models/": ["src/models/"]
}
},
"include": [
"src//*.ts",
"src//*.tsx"
],
"exclude": [
"node_modules", // Exclude the node_modules folder
"dist" // Exclude the dist folder from TypeScript compilation
]
}
Beta Was this translation helpful? Give feedback.
All reactions