w3tecch / typeorm-seeding

🌱 A delightful way to seed test data into your database.
https://www.npmjs.com/package/typeorm-seeding
MIT License
887 stars 132 forks source link

/usr/bin/env: ‘nod’: No such file or directory #99

Closed geritol closed 3 years ago

geritol commented 3 years ago

Hi! I am getting the following when running the cli without ts-node:

$ ./node_modules/typeorm-seeding/dist/cli.js 
/usr/bin/env: ‘nod’: No such file or directory

versions:

geritol commented 3 years ago

Just found that it has been fixed, but not yet released. https://github.com/w3tecch/typeorm-seeding/commit/4dd1bc261f98bc4a3828d2be5901de0e78ecc750

LucienLee commented 3 years ago

could you publish the fix to npm?

AaronNGray commented 3 years ago

I am using the following for now :-

ts-node C:\Users\aaron\GitHub\typeorm-seeding\src\cli.ts seed

There seem to be issues with using the JavaScript compiled version as it does not seem to support ES6 modules.

node node_modules/typeorm-seeding/dist/cli.js

C:\Users\aaron\Tests\vesper\vesper-seeding-example>npm run seed:run

> vesper-example@0.0.1 seed:run
> node ./node_modules/typeorm-seeding/dist/cli.js seed -c sample

🌱  TypeORM Seeding v1.6.1
√ ORM Config loaded
× Could not import factories!
C:\Users\aaron\Tests\vesper\vesper-seeding-example\src\database\factories\pet.factoy.ts:1
import Faker from 'faker';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1025:15)
    at Module._compile (node:internal/modules/cjs/loader:1059:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:816:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at C:\Users\aaron\Tests\vesper\vesper-seeding-example\node_modules\typeorm-seeding\dist\utils\file.util.js:9:141
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
geritol commented 3 years ago

@AaronNGray this signals a problem with your typescript configuration.

The following should work, without needing to alter your original typescript config.

TS_NODE_PROJECT=tsconfig.migrate.json ts-node -r tsconfig-paths/register ./node_modules/typeorm-seeding/dist/cli.js

// tsconfig.migrate.json
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "module": "commonjs"
  }
}
AaronNGray commented 3 years ago

@geritol ts-node C:\Users\aaron\GitHub\typeorm-seeding\src\cli.ts seed works fine.