I've done it before, and documented how, but it wont work, and I'm at my wits end. I cannot for the life of me deploy NestJs in NameCheap cPanel. And I know there are several other posts with small comments, but none of them are helpful.
I've regressed to creating a basic, bare bones nest project and trying to deploy it, but it wont work.
- create new nestjs project with
nest new basic-nestwith only the basic/root get endpoint that returns 'Hello World' from hitting the root endpoint(localhost:3000)
- The only thing I have changed is in main.ts changing await app.listen(3000) to await app.listen(process.env.PORT || 3000);
I thought somewhere that perhaps another api is running on port 3000 thus why not working, so I added the possibility of environment variable...
Also tried enableCors for all because why not
! global enable CORS implemented]3
nest buildIn cPanel, Setup Node.js App, configure as shown below, once created, stop the app to add package and dist files.
Now since creating the 'nest-basic' node application, going to the file manager, within the root home folder, the new folder 'nest-basic' was created. Within this folder I upload my package.json and create a dist folder, where i upload the dist files from 'nest build' from step 3.
Go back to cPanel -> Setup Node.js app -> edit 'nest-basic' app -> Run NPM Install(successful) -> Start App
7.Open the application url and nothing, everytime failure...
I'm not sure whats going wrong, Typescript compiled to JavaScript in the build, so its a NodeJs app, the build is executed through main.js in dist, and the package is installed in Namecheap NodeJS application setup, where I think the only dependency at this basic level that matters in production is @nestjs/core.
An alternate port is provided in environment variables but not necessary and CORS are enabled... One thing that I had previously added in another project was a.npmrc file which only included the text "scripts-prepend-node-path=true", however, adding it next to package.json in the file manager and/or building the app with the file included, same result, failure





