Home > Mobile >  How do I pass more variables to my npm script
How do I pass more variables to my npm script

Time:02-18

I am using typeorm with nextjs. Unfortunately to use manual migrations it seems to be incredibly difficult to get working. Firstly I have the following npm script:

"typeorm": "ts-node -P cli-tsconfig.json -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config ./config/typeorm.config.ts"

This allows me to run:

npm run typeorm migration:run

and it works. However, if I want to create a migration I run:

npm run typeorm migration:create -n mymigration

And it fails with the error:

ts-node -P cli-tsconfig.json -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config ./config/typeorm.config.ts "migration:create" "mymigration"

Missing baseUrl in compilerOptions. tsconfig-paths will be skipped bin.js migration:create

Creates a new migration file.

Options: -h, --help Show help
[boolean] -c, --connection Name of the connection on which run a query. [default: "default"] -n, --name Name of the migration class.
[required] -d, --dir Directory where migration should be created. -f, --config Name of the file with connection configuration. [default: "ormconfig"] -o, --outputJs Generate a migration file on Javascript instead of Typescript [boolean] [default: false] -v, --version Show version number
[boolean]

Missing required argument: n npm ERR! code ELIFECYCLE npm ERR! errno 1

Clearly it's not picking up the parameter but I have no idea how to get around this issue.

CodePudding user response:

Like described in the documentation, you need to separate additional arguments from the npm command with --

npm run typeorm -- migration:create -n mymigration

  • Related