n8n-io/n8n · error · TypeORMError
To use streams you should install pg-query-stream package. P
Error message
To use streams you should install pg-query-stream package. Please run npm i pg-query-stream --save command.
What it means
TypeORMError thrown from PostgresDriver.loadStreamDependency when require('pg-query-stream') throws, i.e. the optional pg-query-stream package is not installed. Streaming query APIs in the postgres driver depend on this optional peer dependency.
Source
Thrown at packages/@n8n/typeorm/src/driver/postgres/PostgresDriver.ts:1305
* Creates an escaped parameter.
*/
createParameter(parameterName: string, index: number): string {
return this.parametersPrefix + (index + 1);
}
// -------------------------------------------------------------------------
// Public Methods
// -------------------------------------------------------------------------
/**
* Loads postgres query stream package.
*/
loadStreamDependency() {
try {
return require('pg-query-stream');
} catch (e) {
// todo: better error for browser env
throw new TypeORMError(
`To use streams you should install pg-query-stream package. Please run npm i pg-query-stream --save command.`,
);
}
}
// -------------------------------------------------------------------------
// Protected Methods
// -------------------------------------------------------------------------
/**
* If driver dependency is not given explicitly, then try to load it via "require".
*/
protected loadDependencies(): void {
try {
const postgres = this.options.driver || require('pg');
this.postgres = postgres;
} catch (e) {
// todo: better error for browser envView on GitHub (pinned to 5ac6606e81)
Solutions
- Install the package in the project that owns the running process: 'npm install pg-query-stream' (or add it to package.json dependencies).
- If you do not need streaming, switch to the non-streaming query API (e.g. find / query) to avoid the dependency entirely.
- Verify the install location is resolvable from the process working dir (not just from a workspace root the runtime cannot see).
Example fix
// before // streaming call fails because pg-query-stream missing // after // run: npm install pg-query-stream await repo.stream();
Defensive patterns
Strategy: validation
Validate before calling
// Probe for the optional dependency at startup, not on first use.
let hasPgQueryStream = false;
try {
require.resolve('pg-query-stream');
hasPgQueryStream = true;
} catch {}
if (!hasPgQueryStream && config.dbType === 'postgres') {
// disable streaming endpoints or fail fast with a clear message
}
Try / catch
import { TypeORMError } from '@n8n/typeorm';
try {
await repository.stream(cb);
} catch (e) {
if (e instanceof TypeORMError && /pg-query-stream/.test(e.message)) {
throw new Error('Streaming requires the pg-query-stream package; install it or use find().');
}
throw e;
}
Prevention
- Declare pg-query-stream as a real dependency if you ship streaming features.
- Probe for optional deps at startup and degrade gracefully.
- Document which driver features require optional packages.
- Avoid streaming APIs in code paths used by minimal deployments.
When it happens
Trigger: Caller invokes a streaming query method (e.g. repository.stream / driver.createQueryRunner streaming) which internally calls loadStreamDependency(), but pg-query-stream is not in node_modules.
Common situations: A deployment uses a custom image that pruned optional deps; a monorepo workspace hoisting dropped the package; the user followed an upstream TypeORM tutorial that assumes pg-query-stream is present.
Related errors
- Postgres package has not been found installed. Try to instal
- Driver not Connected
- SQLite package has not been found installed. Try to install
- Database connection timed out
- Timed out after ${timeoutMs}ms waiting for database connecti
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/1c88e9f302e431eb.
Report an issue: GitHub.