New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'typeorm' does not provide an export named 'Column' #6941
Comments
Can you create a repository that exhibits this? I can't replicate |
i don´t come that far. I got this error when i`m trying to creat a connection with this function: import orm from 'typeorm';
import { Accounts } from './entity/accounts.js';
const SQLConfig = {
type: 'mysql',
host: 'localhost',
port: 3306,
username: 'xxx',
password: 'xxx',
database: 'xxx',
synchronize: true,
logging: false,
entities: [Accounts],
};
var instance = null;
export default class Connection {
constructor() {
if (!instance) {
orm.createConnection(SQLConfig)
.then((con) => {
this.connection = con;
instance = this;
})
.catch((err) => {
throw err;
});
}
return instance;
}
} And if i call this: import SQL from './database/mysql.js';
let db = new SQL(); i get the error import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
^^^^^^
SyntaxError: The requested module 'typeorm' does not provide an export named 'Column' |
Ok - I still am unable to replicate. Can you please create a GitHub repository that includes code which I can |
I can try, but this script i made is a game resource for a Alt:V Server and the js script get executed by the Server |
If you can create a minimal repo that reproduces the issue it'd be best but whatever you can get would help with finding the root cause. |
i can provide you the full repo. with alle Server Files it`s allready on Github but private, let me try to give you rights to it |
I inivted you to a Git Repo there with the hole Projekt. |
Sorry, i`m quite new in Node JS/TypeScript things so the Project Structure may be a bit wyred 🙉 I wasn't prepared for visitors |
Hey there - sorry for taking a while to get to this:
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
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:
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.. 🤷 |
In short - this is an environment issue - and as such, I'll be closing it out. However, for more support on the matter -
|
* feat: support importing TypeORM in esm projects Closes: #6974 Closes: #6941 * bugfix: generate index.mjs directly out of commonjs exports The new implementation generates ESM exports directly out of the commonjs exports, and provides a default export to maintain compatability with existing `import`s of the commonjs implementation * feat: support loading ESM entity and connection config files When TypeORM tries to load an entity file or a connection config file, it will determine what is the appropriate module system to use for the file and then `import` or `require` it as it sees fit. Closes: #7516 Closes: #7159 * fix: adapt ImportUtils.importOrRequireFile tests to older version of nodejs * fix: improved importOrRequireFile implementation * feat: add solution to circular dependency issue in ESM projects * docs: added FAQ regarding ESM projects * chore: add `"type": "commonjs"` to package.json * style * docs: improve `ts-node` usage examples for CLI commands in ESM projects * feat: add support for generating an ESM base project * refactor: renamed `Related` type to `Relation` * docs: added a section in the Getting Started guide regarding the `Relation` wrapper type in ESM projects * docs: improved documentation of the `Relation` type * docs: improved documentation of the `Relation` type * docs: added ESM support to the list of TypeORM features
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:
my Accounts entity
The text was updated successfully, but these errors were encountered: