'Missing required argument: dataSource
I tried to generate migration files with typeorm version 0.3.6.I don't know why but in version 0.2.x it work with the command
npm run typeorm migration:generate -n <file name>
In newest version,I't so mess with me, I get another to another bugs , finally, I think I almost done but I continue get the error
Missing required argument: dataSource
this is scripts in my package.json
"scripts": {
"server": "nodemon dist/index.js",
"watch": "tsc -w",
"test": "echo \"Error: no test specified\" && exit 1",
"typeorm": "ts-node ./node_modules/typeorm/cli.js"
},
ormconfig.json
{
"type":"postgres",
"host":"localhost",
"port":5432,
"username":"postgres",
"password":"",
"database":"test-deploy",
"entities":["dist/entities/*.js"],
"migrations":["dist/migrations/*.js"]
}
dataSource.ts
export const dataSource = new DataSource({
type:"postgres",
username: process.env.PG_USERNAME_DEV,
password: process.env.PG_PASSWORD_DEV,
database: "memories",
synchronize: false,
logging: false,
entities: [Admin,...],
subscribers: [],
migrations: [],
})
//For ApolloServer
export const resolvers : NonEmptyArray<Function> =[AdminResolver,...]
My file structure like this
server
src
...
dist
data-source.js
entities/myEntity.js
and the command i use to generate migration
npm run typeorm migration:generate -n initial -d dist/data-source.js
Am i missing something? How can i fix it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
