typeorm-ts-node-commonjs doesnt work
See original GitHub issueIssue Description
I am trying to run the typeorm cli using typeorm-ts-node-commonjs to generate migrations and it doesn’t work.
Expected Behavior
It should work.
Actual Behavior
mgarcia:~/projects/compliance-backend-api(chore/add-typeorm)$ npm run typeorm
> compliance-backend-api@0.0.1 typeorm
> typeorm-ts-node-commonjs
/usr/bin/env: ‘node --require ts-node/register’: No such file or directory
Steps to Reproduce
"dependencies": {
"@appsignal/express": "^1.0.23",
"@appsignal/nodejs": "^2.2.10",
"cors": "^2.8.5",
"cross-fetch": "^3.1.5",
"dotenv": "^10.0.0",
"envalid": "^7.2.1",
"express": "^4.17.1",
"express-async-handler": "^1.1.4",
"http-terminator": "^3.0.4",
"pg": "^8.7.3",
"pino-http": "^5.8.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^5.5.12",
"typeorm": "^0.3.4",
"ws": "^3.3.3"
},
"devDependencies": {
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"@types/jest": "^27.0.2",
"@types/node": "^16.10.2",
"@types/pino-http": "^5.8.0",
"@types/supertest": "^2.0.11",
"@types/ws": "^8.2.0",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"eslint": "^7.32.0",
"jest": "^27.2.4",
"jest-websocket-mock": "^2.2.1",
"mock-socket": "^9.0.5",
"nodemon": "^2.0.13",typeorm-ts-node-commonjs
"supertest": "^6.1.6",
"ts-jest": "^27.0.5",
"ts-node": "^10.2.1",
"tsc-watch": "^4.5.0",
"typescript": "^4.4.3"
},
"engines": {
"node": ">=16.10.0",
"npm": ">=7.24.0"
}
{
"compilerOptions": {
"target": "es5",
"lib": [
"ES6",
"ES5"
], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
"emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
"module": "commonjs", /* Specify what module code is generated. */
"rootDir": "./src", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
"paths": {
"*": [
"./node_modules/*"
]
},
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"exclude": [
"spec/**/*.ts",
]
}
My Environment
| Dependency | Version |
|---|---|
| Operating System | |
| Node.js version | 16.10.0 |
| Typescript version | 4.4.3 |
| TypeORM version | 0.3.4 |
Additional Context
I used npx typeorm init in my current project.
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, but I don’t know how to start. I would need guidance.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:10 (2 by maintainers)
Top Results From Across the Web
TypeORM error when trying to create migration in CLI
I followed their guide but when I run yarn run typeorm migration:generate I get the error: $ typeorm-ts-node-commonjs migration:generate ...
Read more >typeorm - npm
TypeORM is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and ...
Read more >API with Node.js + PostgreSQL + TypeORM: Project Setup 2022
In this article, you'll learn how to set up a Node.js project with TypeScript, ExpressJs, PostgreSQL, TypeORM, and Redis.
Read more >Complete guide to using TypeORM and TypeScript for data ...
Complete guide to using TypeORM and TypeScript for data persistence in Node.js module ... TypeORM is an advanced object-relations-management ...
Read more >ts-node syntaxerror: cannot use import statement outside a ...
If your project uses ts-node, you can try to add an override in your tsconfig.json, that sets module to commonjs. Make YOU yours...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have the same issue. typeorm-ts-node-esm is broken in the same way.
I was on typeorm v0.3.4 with the same issue.
I upgraded to v0.3.6 and the problem went away, thanks to #8821 (fixed in 0.3.5 actually).