Next.js 9 with custom server(typescript)
See original GitHub issueQuestion about Next.js
before next9 it worked just fine but after upgrading it won’t work is there solution for it??
the tsconfig.json file is
{
"compilerOptions": {
"outDir": "./build",
"allowJs": true,
"target": "esnext",
"lib": ["es2015", "es2016", "es2017", "es2018", "dom"],
"module": "esnext",
"moduleResolution": "node",
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"downlevelIteration": true,
"sourceMap": true,
"typeRoots": ["./@types", "./node_moduels/@types"],
"baseUrl": "./",
"paths": {
"*": ["@types/*"]
},
"strict": true,
"removeComments": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["./**/*"],
"exclude": ["node_moduels", "./build"]
}
and package.json file is
"d": "rm -rf build && cross-env NODE_ENV=development tsc-watch -p tsconfig.json --onSuccess \"node build/index.js\"",
and the error code is
Error: Cannot find module '/Users/peter/Server/theSeed/build/index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
it won’t build properly 😦
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Set Up Next.js with a Custom Express Server + Typescript
In this post, I will walk you through how to make a Next.js application handled by a custom Express server with Typescript.
Read more >Next.js Custom Server Typescript Example - StackBlitz
Run official live example code for Next.js Custom Server Typescript, created by Vercel on StackBlitz.
Read more >zeit/next.js: custom-server-typescript - CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Read more >Advanced Features: Custom Server - Next.js
A custom Next.js server allows you to start a server 100% programmatically in order to use custom server patterns. Most of the time,...
Read more >Custom NextJS Server with Typescript - DEV Community
There is an official NextJS guide on how to create a custom server. However, it only works with JavaScript. Please follow their guide...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
custom-server-typescript example is great, but when running ts-node when you make changes to server/index.ts then it takes good 20-30 sec for the app to re-start as nextjs is deleting the .next folder content and re-generating it, any way to optimize rebuilding of nextjs folder when changes are not in any pages?
I managed to have next js code hot reloaded by adding this to
next.config.js
Important: I’m running my app in a Docker container with docker-compose.yml. So maybe this is not necessary if you’re running the app in your machine.