'typeorm' does not provide an export named 'Column'

See original GitHub issue

Issue type:

[X] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [X] mysql / mariadb [ ] oracle [ ] postgres [ ] cockroachdb [ ] sqlite [ ] sqljs [ ] react-native [ ] expo

TypeORM version:

[X] latest [ ] @next [ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem: If i initialize my MySQL Connection over typeorm with my Accounts entityi get this error:

import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
                     ^^^^^^
SyntaxError: The requested module 'typeorm' does not provide an export named 'Column'

my Accounts entity

import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
@Entity({ name: 'accounts' })
export class Accounts extends BaseEntity {
    @PrimaryGeneratedColumn()
    id: number;

    @Column({ type: 'varchar' })
    username: string;

    @Column({ type: 'varchar' })
    password: string;

    @Column({ type: 'varchar' })
    hardwareID: string;

    @Column({ type: 'int' })
    maxCharacter: number;
} 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
imnotjamescommented, Oct 25, 2020

Hey there - sorry for taking a while to get to this:

  • I cloned the repo
  • I erased altv-server.exe & ran npm run update to grab the linux version of the server
  • I erased node_modules & ran npm install to refresh dependencies
  • I ran npm run build

I’m pretty sure this is some wonk that exists between how Typescript handles module resolution & how nodejs does.

You’re currently using ESM because type: "module" is defined in your package.json.

When importing CommonJS modules, the module.exports object is provided as the default export. Named exports may be available, provided by static analysis as a convenience for better ecosystem compatibility.

TypeORM corrently doesn’t exactly export ESM - it exports commonjs modules. And if static analysis can get you to named exports… great! Except… when it can’t. Like now.

There are two ways you can work around this:

  • Switch your project to have "type": "commonjs" in your package.json & update your tsconfig.json to emit commonjs modules
  • Use the default export provided by TypeORM - import TypeORM from "typeorm"; @TypeORM.Entity();class Foo {}

There’s ONE way that TypeORM could change to help with this as well - export ESM as well as commonJS! I’ll think about adding this but there’s a lot of other things I think might be more important… 🤷

0reactions
imnotjamescommented, Oct 25, 2020

In short - this is an environment issue - and as such, I’ll be closing it out. However, for more support on the matter -

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module '"typeorm"' has no exported member 'Column ...
When I create the project with the typeorm CLI, It dont recognize the modules and shows in red 'Module '"typeorm"' has no exported...
Read more >
Decorator reference | TypeORM Docs
If not specified, TypeORM will generate a enum type from entity and column names - so it's necessary if you intend to use...
Read more >
Database | NestJS - A progressive Node.js framework
In this chapter, we'll demonstrate using the popular MySQL Relational DBMS, but TypeORM provides support for many relational databases, such as PostgreSQL, ...
Read more >
Relations - typeorm - GitBook
Note that they do not reference the primary column of the related entity by default: you must provide the referenced column name.
Read more >
typeorm-extension - npm
If no database is provided, the database name will be equal to the ... PrimaryGeneratedColumn, Column } from 'typeorm'; @Entity() export ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found