3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Windows10でTypeORMのCLIを実行するとエラーがでる

3
Posted at

環境

Windows 10

typeormが実行できない

c:\temp\test-typeorm>.\node_modules\.bin\ts-node .\node_modules\.bin\typeorm  migration:generate  -n Initialize
c:\temp\test-typeorm\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.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\ts-node\src\bin.ts:157:12)
    at Module._compile (module.js:652:30)

下記も同じエラー

c:\temp\test-typeorm>ts-node typeorm  migration:generate  -n Initialize

ts-nodeかまさないと別のエラー

c:\temp\test-typeorm>typeorm  migration:generate  -n Initialize
Error during migration generation:
c:\temp\test-typeorm\models\task.ts:1
(function (exports, require, module, __filename, __dirname) { import {
                                                              ^^^^^^

SyntaxError: Unexpected token import
    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 Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Function.PlatformTools.load (C:\Program Files\nodejs\node_modules\npm\node_modules\typeorm\platform\PlatformTools.js:131:28)

結論

.\node_modules\.bin\ts-node ./node_modules/typeorm/cli.js  migration:run
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?