Closed DutchKevv closed 8 years ago
Hey there,
If you want to deploy this application to your own server, you will need PM2 or forever packages ( as you mentioned )
In both case, you will need to set two variables:
NODE_ENV and PORT
NODE_ENV should be set to production PORT should be set to your forwarded port ( 443 or 80 )
If you are using PM2, you can do that trough process.json http://pm2.keymetrics.io/docs/usage/application-declaration/
I ran npm run build
then on my own server (windows), i've tried both PM2 and nodemon with:
SET NODE_ENV=production && pm2 start bin\www
but get
Error: Cannot find module 'express'
@vladotesanovic please help - what dependencies should be installed on a production server?
@myGuruPitka try to figure out from this, if you can't make it i ll help you more https://github.com/vladotesanovic/angular2-express-starter/issues/46
Thanks @vladotesanovic !
I got it to work after adding to dist/server/packages.json
with the server side dependencies and running npm install
.
"dependencies": {
"body-parser": "~1.13.2",
"compression": "^1.6.2",
"cookie-parser": "~1.3.5",
"core-js": "^2.4.1",
"cors": "^2.8.1",
"express": "^4.13.4",
"express-jwt": "^3.3.0",
"jsonwebtoken": "^5.7.0",
"lodash": "^4.17.2",
"node-uuid": "^1.4.7",
"path": "^0.12.7",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.23"
},
Bit of a noob question, my apologies.
I try to run in production mode, but don't really know what command to use. Had a look at the package.json and found the _server:run scripts, but they are for private use. In app.js there is a reference to app.get('env') === production to set static path to /dist/*
But when I try to run NODE_ENV=production npm start, also doesn't seem to be it.
What is the recommended way to 'run' the production mode? The documentation only states about building prod.
[edit] this seems to do the trick though:
NODE_ENV=production node dist/server/bin/www.js
but still don't know if its the preferred way :)
Incase it is, would it be an idea to add it as a script to the package.json?
npm run prod
Maybe also include npm forever? [/edit]Thanks!