Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

614
Visualizações
TypeORM error when trying to create migration in CLI

I'm trying to use the TypeORM CLI to create a migration. I followed their guide but when I run yarn run typeorm migration:generate I get the error:

$ typeorm-ts-node-commonjs migration:generate
/usr/bin/env: ‘node --require ts-node/register’: No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines
error Command failed with exit code 127.

My package.json looks like this:

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "watch": "tsc -w",
    "start": "node dist/index.js",
    "dev": "nodemon dist/index.js",
    "start2": "ts-node src/index.ts",
    "dev2": "nodemon --exec ts-node src/index.ts",
    "typeorm": "typeorm-ts-node-commonjs"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "apollo-server-express": "^3.6.7",
    "class-validator": "^0.13.2",
    "cors": "^2.8.5",
    "express": "^4.17.3",
    "express-graphql": "^0.12.0",
    "graphql": "^15.3.0",
    "pg": "^8.7.3",
    "reflect-metadata": "^0.1.13",
    "ts-node": "^10.7.0",
    "type-graphql": "^1.1.1",
    "typeorm": "^0.3.4"
  },
  "devDependencies": {
    "@types/express": "^4.17.13",
    "@types/node": "^17.0.23",
    "nodemon": "^2.0.15",
    "typescript": "^4.6.3"
  }
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I managed to solve this by installing the cli as described here https://orkhan.gitbook.io/typeorm/docs/using-cli#installing-cli

Install ts-node globally npm install -g ts-node

add the following script to package.json: "typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js" instead of "typeorm": "typeorm-ts-node-commonjs"

then create a migration with: yarn run typeorm migration:generate -p -d src/data-source.ts src/migrations/<filename without ending>

FYI For anyone facing similar issues: It took me a while to figure out that the various documentations on typeorm are confusing and conflicting at the moment because they just moved to v0.3.0 and not everything has been updated.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda