julekgwa julekgwa - 1 year ago 131
Node.js Question

How to git pull before npm start with Nodejs

I'm trying to pull my files from git before running my app, I'm using

git pull && node ./bin/www
and the application hangs.I'm new to
Is there another way of doing this?

"name": "matcha",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "git pull && node ./bin/www"
"dependencies": {
"base-64": "^0.1.0",
"bcryptjs": "^2.3.0",
"body-parser": "~1.15.2",
"cookie-parser": "~1.4.3",
"crypto": "0.0.3",
"debug": "~2.2.0",
"ejs": "~2.5.2",
"express": "~4.14.0",
"express-session": "^1.14.2",
"fs": "0.0.1-security",
"morgan": "~1.7.0",
"multer": "^1.2.0",
"mysql": "^2.12.0",
"nodemailer": "^2.6.4",
"path": "^0.12.7",
"serve-favicon": "~2.3.0"
"repository": {
"type": "git",
"url": "https://github.com/julekgwa/Matcha.git"

enter image description here

Answer Source

You can use prestart.

When you are updating your dependencies, you need run npm install. So scripts example is:

"scripts": {
  "prestart": "git pull && npm install",
  "start": "node ./bin/www"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download