Cannot Build for deployment
Answered
Horse guard wasp posted this in #help-forum
Horse guard waspOP
Hello everyone, https://github.com/amankhanal1960/buildcheck.git, this is small part of the project i am making, and for some reason the typescript is always throwing this error. Could you please solve this error please. ANY HELP WOULD BE APPRECIATED!!!
$ pnpm build
▲ Next.js 15.1.6
- Environments: .env
Creating an optimized production build ...
✓ Compiled successfully
Linting and checking validity of types .Failed to compile.
.next/types/app/api/blogs/[id]/route.ts:205:7
Type error: Type '{ tag: "PUT"; param_position: "second"; param_type: { params: { id: string; }; }; }' does not satisfy the constraint 'ParamCheck<RouteContext>'.
The types of 'param_type.params' are incompatible between these types.
Type '{ id: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
203 | Diff<
204 | ParamCheck<RouteContext>,
206 | tag: 'PUT'
207 | param_position: 'second'
208 | param_type: SecondArg<MaybeField<TEntry, 'PUT'>>
Static worker exited with code: 1 and signal: null
ELIFECYCLE Command failed with exit code 1., this is the error i get everytime i try to build this project,
$ pnpm build
building@0.1.0 build E:\Next\building
next build
▲ Next.js 15.1.6
- Environments: .env
Creating an optimized production build ...
✓ Compiled successfully
Linting and checking validity of types .Failed to compile.
.next/types/app/api/blogs/[id]/route.ts:205:7
Type error: Type '{ tag: "PUT"; param_position: "second"; param_type: { params: { id: string; }; }; }' does not satisfy the constraint 'ParamCheck<RouteContext>'.
The types of 'param_type.params' are incompatible between these types.
Type '{ id: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
203 | Diff<
204 | ParamCheck<RouteContext>,
205 | {| ^
206 | tag: 'PUT'
207 | param_position: 'second'
208 | param_type: SecondArg<MaybeField<TEntry, 'PUT'>>
Static worker exited with code: 1 and signal: null
ELIFECYCLE Command failed with exit code 1., this is the error i get everytime i try to build this project,
Answered by joulev
export async function PUT(
request: NextRequest,
- { params }: { params: { id: string } }
+ { params }: { params: Promise<{ id: string }> }
): Promise<Response> {
- const { id } = params;
+ const { id } = await params;
and do the same thing for other methods as well
2 Replies
@Horse guard wasp Hello everyone, https://github.com/amankhanal1960/buildcheck.git, this is small part of the project i am making, and for some reason the typescript is always throwing this error. Could you please solve this error please. ANY HELP WOULD BE APPRECIATED!!!
$ pnpm build
> building@0.1.0 build E:\Next\building
> next build
▲ Next.js 15.1.6
- Environments: .env
Creating an optimized production build ...
✓ Compiled successfully
Linting and checking validity of types .Failed to compile.
.next/types/app/api/blogs/[id]/route.ts:205:7
Type error: Type '{ __tag__: "PUT"; __param_position__: "second"; __param_type__: { params: { id: string; }; }; }' does not satisfy the constraint 'ParamCheck<RouteContext>'.
The types of '__param_type__.params' are incompatible between these types.
Type '{ id: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
203 | Diff<
204 | ParamCheck<RouteContext>,
> 205 | {
| ^
206 | __tag__: 'PUT'
207 | __param_position__: 'second'
208 | __param_type__: SecondArg<MaybeField<TEntry, 'PUT'>>
Static worker exited with code: 1 and signal: null
ELIFECYCLE Command failed with exit code 1., this is the error i get everytime i try to build this project,
export async function PUT(
request: NextRequest,
- { params }: { params: { id: string } }
+ { params }: { params: Promise<{ id: string }> }
): Promise<Response> {
- const { id } = params;
+ const { id } = await params;
and do the same thing for other methods as well
Answer