我正在尝试从 CLI 在 Vercel( https://vercel.com ,之前)部署一个 API(在 Node 中制作)。但是当我部署应用程序时,我打开站点,结果只是路径目录中的文件,而不是正在运行的应用程序。这是我的 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
原文由 NuzzeSicK 发布,翻译遵循 CC BY-SA 4.0 许可协议
运行
yarn global add now@latest
安装 CLInow.json
文件并粘贴这个注意:将
"src": "server.js",
&&"dest":"server.js"
更改为您的服务器条目文件。将其添加到
.gitignore
然后在 CLI 中运行
now
进行部署。如果您要部署到生产环境,请在 CLI 中使用
now --prod
命令进行部署这是我部署的示例服务器:https: //vercel-example-server.now.sh 。