我正在尝试在 Vercel (https://vercel.com https://vercel.com,之前的 Now)来自 CLI。但是,当我部署应用程序时,我打开站点,结果只是路径目录中的文件,而不是正在运行的应用程序。这是我的server.js
{
"name": "subtitles-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node server.js",
"pre-deploy": "node deleteLastDeploy.js",
"deploy": "npm run pre-deploy && now --public && now alias",
"test": "echo \"Error: no test specified\" && exit 1"
}
"engines": {
"node": ">=6.9"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
//list of dependencies
}
}
要查看完整的 API:https://github.com/bitflix-official/subtitles-api https://github.com/bitflix-official/subtitles-api
Run yarn global add now@latest
安装 CLI
- 创建一个
now.json
归档并粘贴此内容
{
"version": 2,
"builds": [{
"src": "./server.js",
"use": "@now/node-server"
}],
"routes": [{"handle": "filesystem"},
{
"src": "/.*",
"dest": "server.js"
}
]
}
Note: 改变"src": "server.js",
&&"dest":"server.js"
到您的服务器条目文件。
-
将其添加到.gitignore
-
然后运行now
在 CLI 中进行部署。
如果您要部署到生产使用now --prod
CLI 中的命令进行部署
这是我部署的示例服务器:https://vercel-example-server.now.sh https://vercel-example-server.now.sh.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)