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

Generate & Run Doc section doesn't work as described #204

Closed
Jrfidellis opened this issue Sep 5, 2018 · 5 comments
Closed

Generate & Run Doc section doesn't work as described #204

Jrfidellis opened this issue Sep 5, 2018 · 5 comments
Labels

Comments

@Jrfidellis
Copy link
Contributor

Jrfidellis commented Sep 5, 2018

Running npm run migration:generate -- -n TestMigration (as proposed in https://foalts.gitbook.io/docs/databases/generate-and-run-migrations) displays the following error on Windows 10:

error.txt

@Jrfidellis Jrfidellis changed the title Generate & Run Doc session doesn't work as described Generate & Run Doc section doesn't work as described Sep 5, 2018
@LoicPoullain
Copy link
Member

Hi @Jrfidellis

Thanks for reporting this error.

npm run migration:generate -- -n TestMigration

> test-app@0.0.0 migration:generate C:\Users\joao.fidellis\Desktop\test-app> ts-node ./node_modules/.bin/typeorm migration:generate "-n" "TestMigration"

C:\Users\joao.fidellis\Desktop\test-app\node_modules.bin\typeorm:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\,/,g')")
^^^^^^^

SyntaxError: missing ) after argument list
	at createScript (vm.js:80:10)
	at Object.runInThisContext (vm.js:139:10)
	at Module._compile (module.js:616:28)
	at Object.Module._extensions..js (module.js:663:10)
	at Module.load (module.js:565:32)
	at tryModuleLoad (module.js:505:12)
	at Function.Module._load (module.js:497:3)
	at Function.Module.runMain (module.js:693:10)
	at Object. (C:\Users\joao.fidellis\Desktop\test-app\node_modules\ts-node\src\bin.ts:147:12)
	at Module._compile (module.js:652:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-app@0.0.0 migration:generate: ts-node ./node_modules/.bin/typeorm migration:generate "-n" "TestMigration"
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test-app@0.0.0 migration:generate script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.`

It looks like that this error is specific to TypeORM (see typeorm/typeorm#2316).

However as entities are all compiled to JavaScript in FoalTS, I think we can get rid of ts-node to generate, run and revert the migrations.

I updated the package.json with the following lines:

{
  ...
  "migration:generate": "./node_modules/.bin/typeorm migration:generate",
  "migration:run": "./node_modules/.bin/typeorm migration:run",
  "migration:revert": "./node_modules/.bin/typeorm migration:revert"
  ...
}

I tested it on Windows and Mac OS and it seems to work. Could you confirm on your host?

@Jrfidellis
Copy link
Contributor Author

It's working properly now @LoicPoullain, thanks!

@Jrfidellis
Copy link
Contributor Author

I took the liberty to open a PL with those changes.

@LoicPoullain
Copy link
Member

👌

@LoicPoullain LoicPoullain added this to In Progress in Issue tracking Sep 6, 2018
@LoicPoullain LoicPoullain mentioned this issue Sep 6, 2018
10 tasks
LoicPoullain added a commit that referenced this issue Sep 7, 2018
Correcting typeorm scripts - Issue #204
@LoicPoullain
Copy link
Member

Fixed in v0.6.0-beta.4.

Issue tracking automation moved this from In Progress to Done Sep 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Issue tracking
  
Done / Closed This Release
Development

No branches or pull requests

2 participants