gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 23:28:54 25 4
gpt4 key购买 nike

我试图在运行应用程序之前从 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com