Closed stevenlafl closed 1 year ago
Okay, it's a typescript issue. I fixed it with this:
view.service.ts
import { Injectable, OnModuleInit } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import * as createServer from 'next';
import { NextServer } from 'next/dist/server/next';
@Injectable()
export class ViewService implements OnModuleInit {
private server: NextServer;
constructor(private configService: ConfigService) {}
async onModuleInit(): Promise<void> {
try {
// @ts-ignore
this.server = createServer({
dev: this.configService.get<string>('NODE_ENV') !== 'production',
dir: './src/client',
});
await this.server.prepare();
} catch (error) {
console.error(error);
}
}
getNextServer(): NextServer {
return this.server;
}
}
You shouldn't mix docker and native setup.
A clean docker-compose up
works fine on my system and worked in the CI last time as well (although logs are no longer available)). What is your native OS?
Debian Linux
I cloned, and ran docker-compose up
. No node_modules, etc. That's how I got the yarn problem at the start.
Thanks! I fixed the docker issue by updating the node version in the dockerfiles: https://github.com/thisismydesign/nestjs-starter/pull/431 You can git pull
the fix.
The other issue I think is related to mixing native and docker setup. I recommend the docker setup but you can also do yarn install && yarn start:dev
natively, it should work. Just don't mix the two (e.g. yarn install && docker-compose up
).
I'm closing for now but feel free to ping me if you run into further issues.
Followed exact "usage" instructions. Can't get it to run.
This was
docker-compose up
So I ran
on the host machine. Uh, no problems. Weird, very weird. Tried
docker-compose up
again, got:Okay, obviously it can't use the server method mentioned here, which is what you're doing in the code: https://nextjs.org/docs/pages/building-your-application/configuring/custom-server
Nonetheless, I go visit
/home
and I see: