question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migrations CLI fail with error: TypeError: dataSourceFileExports is not iterable

See original GitHub issue

Issue Description

Steps to Reproduce

I am following the documentation and installing typeORM with the command: npx typeorm init --name MyProject --database postgres

running migrations with this command: yarn typeorm migration:show -d ./src/data-source.ts

will fail with the error: TypeError: dataSourceFileExports is not iterable at Function.loadDataSource (/Users/GitHub/MyProject/src/commands/CommandUtils.ts:37:34) at async Object.handler (/Users/GitHub/MyProject/src/commands/MigrationShowCommand.ts:27:26)

data-source.ts looks like this:

import "reflect-metadata"
import { DataSource } from "typeorm"
import { User } from "./entity/User"

export const AppDataSource = new DataSource({
    type: "postgres",
    host: "localhost",
    port: 5432,
    username: "test",
    password: "test",
    database: "test",
    synchronize: true,
    logging: false,
    entities: [User],
    migrations: [],
    subscribers: [],
})

My Environment

Dependency Version
Operating System MacOS
Node.js version v18.8.0
Typescript version 4.5.2
TypeORM version 0.3.8

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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:8
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
backnightcommented, Aug 28, 2022

Downgrade to 0.3.4 solved the issue on my side (temporary solution).

Also, don’t forget to force the version “0.3.4” in package.json and not set it like “^0.3.4” because in that case, it will be the buggy 0.3.8 version that will be installed 😉

3reactions
boclair-temgouacommented, Aug 28, 2022

Downgrade to 0.3.7 solved the issue on my side (temporary solution).

Also, don’t forget to force the version “0.3.7” in package.json and not set it like “^0.3.7” because in that case, it will be the buggy 0.3.8 version that will be installed 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typeorm CLI not usable - Running CLI returns: TypeError ...
typeorm.config.ts Error during migration generation: TypeError: dataSourceFileExports is not iterable at Function.
Read more >
Error when creating a new migration using TypeORM and ...
I have a node application using typescript and I'm trying to create a new migration, following the documentation of the TypeORM. First I ......
Read more >
Migrations - typeorm - GitBook
A migration is just a single file with sql queries to update a database schema and apply new changes to an existing database....
Read more >
27884 (Document that validators needs to be an iterable since ...
However, if this migration is loaded by Django 1.11 when running migrate or makemigrate or ... later TypeError: 'MinValueValidator' object is not iterable....
Read more >
Upgrade Sentry 20.9 to 21.3 - On-Premise
@BYK Running migrations: Applying ... filter_expr TypeError: 'int' object is not iterable An error occurred, ... Parsing command line .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found