Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typeorm cli migrate:run port issue getting "config.options.port" property must be of type number. #6781

Closed
GLakshmiSravanthi opened this issue Sep 25, 2020 · 3 comments · Fixed by #6786

Comments

@GLakshmiSravanthi
Copy link

Issue type:

[x ] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[x ] mssql
[ ] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[x ] latest
[ ] @next
[ ] 0.x.x (or put your version here)

While running the yarn ts-node ./node_modules/typeorm/cli.js migration:run facing error
We are using .env file, which has the typeORM configuration.

error

Configarations we placed


TYPEORM_CONNECTION=mssql
TYPEORM_HOST=localhost
TYPEORM_PORT=1443
TYPEORM_USERNAME=XXXX
TYPEORM_PASSWORD=XXXX
TYPEORM_DATABASE=test
TYPEORM_SYNCHRONIZE=false
TYPEORM_LOGGING=error
TYPEORM_LOGGER=advanced-console

this our script file from here we are running db.migrate
image

Solutions we tried

[ * ] This is our folder structure placed .env file and ormconfig.json are in same folder but when we are running migrations command it is taking .env file not ormconfig.json
image

[ * ] We tried to giving yarn ts-node ./node_modules/typeorm/cli.js migration:run -f ormconfig.json but we are unable to compile
image

[ * ] But by renaming the .env file we are able to compile the command yarn ts-node ./node_modules/typeorm/cli.js migration:run -f ormconfig.json
image

[ * ] We tried pass our .env file as configuration, it results the same error
image

[ * ] Checked in the typeorm git repo in that ConnectionOptionsEnvReader() is reading the env variables and in that port is read from port: PlatformTools.getEnvVariable("TYPEORM_PORT"), . getEnvVariables is returning a string.
Which may be causing the issue ?
Please help

Thankyou For advance

@imnotjames
Copy link
Contributor

Yeah - looks like that's the case - it doesn't coerce the port to a number when pulling from env to a string.

Pull requests welcome :) But we'd need to double check that none of the drivers actually EXPECT a string port.

@imnotjames
Copy link
Contributor

As a temporary workaround, are you able to omit the port environment variable? Or stick with the ormconfig.json? The default should be 1443

imnotjames added a commit to imnotjames/typeorm that referenced this issue Sep 25, 2020
the expected type of `port` in all drivers is a number - and
in MSSQL this is a problem as the underlying driver does not
properly handle a string port - so we have to parseInt

closes typeorm#6781
imnotjames added a commit to imnotjames/typeorm that referenced this issue Sep 25, 2020
the expected type of `port` in all drivers is a number - and
in MSSQL this is a problem as the underlying driver does not
properly handle a string port - so we have to parseInt

closes typeorm#6781
pleerock pushed a commit that referenced this issue Sep 26, 2020
the expected type of `port` in all drivers is a number - and
in MSSQL this is a problem as the underlying driver does not
properly handle a string port - so we have to parseInt

closes #6781
@GLakshmiSravanthi
Copy link
Author

GLakshmiSravanthi commented Oct 2, 2020

thankyou we resolved the problem
by adding the -f loader path by taking the reference from this
https://dzone.com/articles/integration-of-dotenv-with-nestjs-and-type-orm

zaro pushed a commit to zaro/typeorm that referenced this issue Jan 12, 2021
the expected type of `port` in all drivers is a number - and
in MSSQL this is a problem as the underlying driver does not
properly handle a string port - so we have to parseInt

closes typeorm#6781
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants