Deployment on IIS of Nestjs application - node.js

I have tried to deploy my Nestjs deploying on IIS server. I have configured iisnode on IIS that works fine for express application but I am getting errors for missing modules for nestjs. I have tried following commands for building production package
npm run start:prod
and
npm run webpack
but failed to deploy on IIS. How can I build a deployment package?? so I can deploy. I am new with nodejs and Nestjs.

Look at the project's package.json. You'll see that start:prod is a script that runs node on the compiled output of the project. You get the compiled output by running:
npm run prestart:prod
that will re-build your app into the dist folder.
So you can
Zip up the dist folder
deploy to the target host
Unzip it
Try running iisnode on it
let me know how that works

Related

Missing files in .bin folder when deploying Node App to Azure App Service

So I was trying to deploy my react app to an Azure Web App.
I used a Github Action to build and install the App and then ZIP Deploy it to Azure.
The Problem is that once I open up the WebApp Page it shows me an Application Error (react-scripts could not be found).
I found out that once I copy the react-scripts.cmd / ps1 (from local /node_modules/.bin) to the node_modules/.bin folder of the webapp "https://{WEBAPP-NAME}.scm.azurewebsites.net" it works.
Unfortunately I would have to do that after every build.
How can I come up with a solution to this error?
What I already tried:
Update node and npm
Remove package-lock
Thanks in advance
Max
My package.json:
It looks like this issue: npm package.json scripts not being called
Try running npm run-script if you want to execute a script that is not executed by a built-in npm command.
So I found out, that react-scripts is only working in dev environments. But Azure uses a production env. Therefore the github action not only has to install the prod node_modules (npm install) but also the dev modules (npm install --only=dev).
Reference:
https://github.com/mars/create-react-app-buildpack/issues/32#issuecomment-276081892

can we deploy an react js application without source(src folder) code locally

some background:this is my first react application and my assumption is build in react is similar to binary files in c++
question : this is for a react application which sole purpose is to run locally. is there anyway we can do npm start only with build
have tried to delete the src folder after building.
expected result is the app should run as usual.
actual result : app crashes saying, index.js file is missing
npm start won`t work with build version,
you need to install serve and run build using serve locally on your machine
npm install -g serve
serve -s build
ref: https://facebook.github.io/create-react-app/docs/deployment

How to deploy angular app to production

I'm a little uncertain about some Angular 5 aspects. I've developed an app and don't know how to run it on production.
Currently I run my app using ng serve in NodeJS , but is it same in a production environment ?
thanks!
ng serve
ng serve is for development purpose. Check docs.
When using ng serve the compiled output is served from memory, not from disk.
This means that the application being served is not located on disk in the dist folder.
ng build
ng build --prod is for production purpose. Check docs.
ng build compiles the application into an output directory.
The build artifacts will be stored in the dist/ directory, inside the root directory of your angular app.
Jus copy the dist folder to any server like IIS or Node Express and your angular app is up and running.
To deploy you app using IIS check this and using Node Express check this.
Generally, I do not use Angular CLI's built in web server for production deployments.
With Angular CLI, you can create a production build using this command
ng build –prod
That will create a dist folder, which you can upload to any web server of your choosing to deploy an application.
First and foremost, you should build your app for production using
ng build --prod
You'll find a dist folder in your project folder. This is the Production-ready version of your app.
Now you'd require a server to deploy your app. Install this - https://www.npmjs.com/package/http-server and run using http-server dist/myProject (replace myProject with your project name)
ng build generate production files in outDir folder.
To know where it is, go to .angular-cli.json file and see apps > outDir property. For example:
"apps": [
{
"root": "src",
"outDir": "../../webapp/recorder",
"assets": [
"assets",
"favicon.ico"
],
...
These files are only html, css and javascript and can be used on any web server
Follow this instruction by using Angular CLI:
1- Build your project (for production mode)
ng build --prod
2- If you want to see your project in production mode before deploy it on the real server you can use lite-server to serve your project in a local machine.
First install lite-server
npm i lite-server --save-dev
And then run your project on local server
lite-server --baseDir="dist/your-project-name"

Deploy react redux starter kit on Heroku

I downloaded the starter kit for react and redux. It's really nice and works fine in localhost with the command npm run dev but I'm not able to deploy it on the server.
First, I use the command npm run deploy which clean and compile my src folder in the dist folder. Then, I deploy the server on Heroku. Once all is built, the server run npm start which execute the command babel-node bin/server. This command is not recognized by the heroku server.
I would really appreciate if someone could help me to debug this. I tried to clone again the repo, then :
npm install
npm run deploy
Publish on Heroku and I have the same error without changing anything on the code.
The reason it doesn't work on heroku is because there isn't any production server ready in this project for your deployment as specified here : https://github.com/davezuko/react-redux-starter-kit#deployment
When you run the npm run deploy command, all the front-end code is compiled in the /dist folder.
In order to deploy it on heroku you need to :
Create a very simple http server always serving the file index.html. Here is the main part using Express or Koa
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/dist/index.html'));
});
Modifying the npm start script in order to target this new production ready server.

Can't deploy nodejs app to heroku and openshift

I can't deploy my ExpressJS app to Heroku or OpenShift hosting. On my MacBook Pro all works perfectly, but it go to crash when I try to deploy it on hosting.
error Error: shasum check failed for /app/tmp/npm-403-gj-8PMyB/1387967953013-0.7812028499320149/tmp.tgz
344 error Expected: f99cd60b91df7e6669c59ac2b55c4bfc65ff9494
344 error Actual: c4a5f6cf7f807d89d1aa0babe686b434426206b6
openshift log, heroku log
I had the same problem on Heroku before that I did not figure out what caused it.But this is how I fixed mine:
first remove the dependency (in your case it could be process-pwd ) from package.json file
open the terminal app on your mac and go to you project folder
run the install command for the package that fails
npm install moduleName
this will install a local copy of the module in your project folder inside node_modules folder
deploy the app again
Hope this works but you have to figure out which module actually fails :)

Resources