node.js - 如何在 Nodejs 启动 npm 之前进行 git pull

标签 node.js npm

我试图在运行应用程序之前从 git 中提取文件,我正在使用 git pull && node ./bin/www 并且应用程序挂起。我是 Nodejs 的新手,还有其他方法可以做到这一点吗?

{
  "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

最佳答案

您可以使用预启动

更新依赖项时,需要运行npm install。所以脚本示例是:

"scripts": {
  "prestart": "git pull && npm install",
  "start": "node ./bin/www"
}

关于node.js - 如何在 Nodejs 启动 npm 之前进行 git pull,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40584352/

相关文章:

node.js - 如何通过 https 在生产服务器上使用 Laravel Echo

node.js - 如何忽略与 Istanbul 尔的 promise 的所有失败案例

javascript - 我可以使用 npm 为基于 PHP 的网站安装 Fabric.js 吗?

mysql - bcrypt@1.0.3 安装 : `node-pre-gyp install --fallback-to-build`

javascript - 如何链接 CSS 和 Jade?

node.js - 将 Sequelize CLI 与 ESM 包结合使用

node.js - http statusCode 有时未定义

私有(private) Linux 主机上的 Node.js 应用程序

javascript - 从 NodeJS 控制 Arduino

npm - 使用 Gulp 时捕获和处理 Uglify 错误