Nest (NestJS) is a framework for building efficient, scalable Node.js server-side applications.
Please follow the deployment instructions:
1. install the Nest CLI and create a new project
npm i -g @nestjs/cli
nest new project-name
2. change the highlighted content in the main.ts file and ensure that you do NOT define the variable "PORT" in the .env file
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
const port = process.env.PORT || 3000;
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(port);
}
bootstrap();
3. run the application in the development environment
cd project-name
npm run start
4. design your application, test it with the development server, prepare to deploy the application
npm run build
it will generate the production files in dist folder
5. upload all the files in dist folder and upload the entire node_modules folder to your website via FTP client
7. replace the contents of the root web.config with the following:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="main.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="mysite">
<match url="/*" />
<action type="Rewrite" url="main.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Article ID: 2259, Created: June 21, 2023 at 5:18 AM, Modified: June 21, 2023 at 5:19 AM