当我尝试运行 Next.js 应用程序时,npm run dev
收到一条错误消息,指出我没有使用 Typescript 运行 Next 所需的包:
Please install @types/react by running:
npm install --save-dev @types/react
If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files in your pages directory).
Run Code Online (Sandbox Code Playgroud)
但是,已安装模块“@types/react”。我尝试运行npm install --save-dev @types/react
并没有收到任何错误消息(只是一堆警告,但我不认为它们是问题所在)。
我该如何解决这个问题并运行该项目?
我有一个带有 REST 模块和 GraphQL 模块的Nest.js应用程序。两者都导入到App.module.ts
. 我正在使用 Nest 的Throttler Guard来保护整个应用程序。众所周知,GraphQL 不能与普通的 一起使用ThrottlerGuard
,因此我创建了一个GqlThrottlerGuard
并将其导入到 GraphQL 模块上,同时将原始的导入ThrottlerGuard
到 REST 模块上。
所以,我的 graphQL 模块如下所示:
@Module({
imports: [
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDriver,
autoSchemaFile: true
}),
ThrottlerModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (config: ConfigService) => ({
ttl: config.get('security.throttle.ttl'),
limit: config.get('security.throttle.limit'),
}),
}),
],
providers: [
{
provide: APP_GUARD,
useClass: GqlThrottlerGuard,
},
],
})
export class GraphModule { }
Run Code Online (Sandbox Code Playgroud)
还有 REST 模块,如下所示:
@Module({
imports: [
ThrottlerModule.forRootAsync({
imports: …
Run Code Online (Sandbox Code Playgroud) typescript ×2
graphql ×1
javascript ×1
nestjs ×1
next.js ×1
node.js ×1
npm ×1
reactjs ×1
rest ×1