装饰器插件需要一个 'decoratorsBeforeExport' 选项
The decorators plugin requires a 'decoratorsBeforeExport' option
我正在使用 Next.js 和打字稿。我也在尝试使用 TypeORM,就像这样:
@Entity()
export class UserModel extends BaseEntity {
@PrimaryGeneratedColumn('uuid')
id: number
}
但是我收到一个错误:
Error: [BABEL] /home/aironside/Documents/private/tatooify/pages/api/user.ts: The decorators plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean. If you want to use the legacy decorators semantics, you can set the 'legacy: true' option.
这是我的 .babelrc
{
"presets": ["next/babel"],
"plugins": [
"@babel/plugin-proposal-decorators", {
"legacy": true
},
]
}
这是相关的 package.json 部分
{
"dependencies": {
"@babel/plugin-proposal-decorators": "^7.12.13",
...
},
"devDependencies": {
...
}
}
根据我的发现,大多数错误是由于未安装此插件或它在 devDep 而不是依赖项中引起的。我错过了什么?
好的,如图docs(很明显).babelrc应该是这样的:
{
"presets": ["next/babel"],
"plugins": [
["@babel/plugin-proposal-decorators", {"legacy": true}]
]
}
注意插件名称和选项对象周围的 []。
我正在使用 Next.js 和打字稿。我也在尝试使用 TypeORM,就像这样:
@Entity()
export class UserModel extends BaseEntity {
@PrimaryGeneratedColumn('uuid')
id: number
}
但是我收到一个错误:
Error: [BABEL] /home/aironside/Documents/private/tatooify/pages/api/user.ts: The decorators plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean. If you want to use the legacy decorators semantics, you can set the 'legacy: true' option.
这是我的 .babelrc
{
"presets": ["next/babel"],
"plugins": [
"@babel/plugin-proposal-decorators", {
"legacy": true
},
]
}
这是相关的 package.json 部分
{
"dependencies": {
"@babel/plugin-proposal-decorators": "^7.12.13",
...
},
"devDependencies": {
...
}
}
根据我的发现,大多数错误是由于未安装此插件或它在 devDep 而不是依赖项中引起的。我错过了什么?
好的,如图docs(很明显).babelrc应该是这样的:
{
"presets": ["next/babel"],
"plugins": [
["@babel/plugin-proposal-decorators", {"legacy": true}]
]
}
注意插件名称和选项对象周围的 []。