[英]Deployment on Vercel fails because cannot convert undefined or null to object
I'm trying to deploy a proxy by using this repository: https://github.com/theBliz/cmc-proxy .我正在尝试使用此存储库部署代理: https://github.com/theBliz/cmc-proxy 。 (I basically cloned the entire repository, and the only thing I changed is an API key which is required to use an API)
(我基本上克隆了整个存储库,我唯一更改的是使用 API 所需的 API 密钥)
However when I try to deploy the project on Vercel, I get the following error:但是,当我尝试在 Vercel 上部署项目时,出现以下错误:
Error: Cannot convert undefined or null to object
The full logs is:完整的日志是:
2022-09-30T08:14:05.536Z Retrieving list of deployment files...
2022-09-30T08:14:05.777Z
2022-09-30T08:14:08.322Z Downloading 8 deployment files...
2022-09-30T08:14:08.949Z Looking up build cache...
2022-09-30T08:14:09.390Z Build Cache not found
2022-09-30T08:14:09.423Z Running "vercel build"
2022-09-30T08:14:09.921Z Vercel CLI 28.4.4
2022-09-30T08:14:10.051Z WARN! Due to `builds` existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings
2022-09-30T08:14:10.061Z > Installing Builder: @now/node-server
2022-09-30T08:14:13.072Z downloading user files...
2022-09-30T08:14:13.073Z installing dependencies for user's code...
2022-09-30T08:14:13.083Z Installing dependencies...
2022-09-30T08:14:13.084Z Detected `package-lock.json` generated by npm 7+...
2022-09-30T08:14:15.802Z npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
2022-09-30T08:14:16.162Z npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
2022-09-30T08:14:16.292Z npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
2022-09-30T08:14:16.341Z npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
2022-09-30T08:14:17.430Z npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
2022-09-30T08:14:17.903Z npm WARN deprecated axios@0.18.1: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
2022-09-30T08:14:18.310Z
2022-09-30T08:14:18.310Z added 296 packages in 5s
2022-09-30T08:14:18.311Z
2022-09-30T08:14:18.311Z 8 packages are looking for funding
2022-09-30T08:14:18.311Z run `npm fund` for details
2022-09-30T08:14:18.327Z running user script...
2022-09-30T08:14:18.330Z preparing lambda files...
2022-09-30T08:14:18.330Z compiling entrypoint with ncc...
2022-09-30T08:14:18.595Z ncc: Version 0.18.5
2022-09-30T08:14:18.596Z ncc: Compiling file index.js
2022-09-30T08:14:20.362Z Error: Cannot convert undefined or null to object
This is my now.json:这是我的 now.json:
{
"version": 2,
"name": "cmc-proxy",
"builds": [{ "src": "proxy.js", "use": "@now/node-server" }],
"routes":[{
"src": "/(.*)", "dest": "proxy.js"
}],
"env": {
"CMC_API_KEY": "@cmc_api_key"
}
}
The project does not have an index.js file, and it seems like the error is being thrown when its trying to compile index.js.该项目没有 index.js 文件,似乎在尝试编译 index.js 时抛出错误。 I'm just trying to deploy a proxy so that I can use a certain API from the client side instead of building a full backend.
我只是想部署一个代理,这样我就可以从客户端使用某个 API 而不是构建一个完整的后端。
When I run "npm start" to run it locally, I dont have any issues and I can use the project.当我运行“npm start”在本地运行它时,我没有任何问题,我可以使用该项目。
How can I solve this issue?我该如何解决这个问题?
I solved the problem, instead of using "@now/node-server", it should be "@vercel/node".我解决了这个问题,而不是使用“@now/node-server”,它应该是“@vercel/node”。 The former is deprecated
前者已弃用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.