【发布时间】:2021-07-29 08:06:29
【问题描述】:
当我运行 npx typeorm migration:run 时出现这样的错误:
语法错误:不能在模块外使用 import 语句。
我问了很多人,我不知道如何解决。 这是我的 ormconfig 和我的 package.json 分别:
{
"type": "postgres",
"host": "localhost",
"port": 5432,
"username": "docker",
"password": "docker",
"database": "db_project_manager",
"entities": [
"./src/models/**/*.ts"
],
"migrations": [
"./src/database/migrations/**/*.ts"
],
"cli": {
"migrationsDir": "./src/database/migrations"
}
}
{
"name": "backend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "ts-node-dev --inspect --transpile-only --ignore-watch node_modules src/server.ts",
"typeorm": "ts-node-dev ./node_modules/typeorm/cli.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"pg": "^8.6.0",
"reflect-metadata": "^0.1.13",
"typeorm": "0.2.24"
},
"devDependencies": {
"@types/express": "^4.17.11",
"eslint": "^6.8.0",
"ts-node-dev": "^1.1.6",
"typescript": "^4.2.4",
"@typescript-eslint/eslint-plugin": "^3.4.0",
"@typescript-eslint/parser": "^3.4.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-plugin-import": "^2.21.2",`enter code here`
"eslint-plugin-prettier": "^3.1.4"enter code here
}
}
【问题讨论】:
标签: typescript typeorm