簡體   English   中英

在 Vercel 上部署失敗,因為無法將 undefined 或 null 轉換為 object

[英]Deployment on Vercel fails because cannot convert undefined or null to object

我正在嘗試使用此存儲庫部署代理: https://github.com/theBliz/cmc-proxy (我基本上克隆了整個存儲庫,我唯一更改的是使用 API 所需的 API 密鑰)

但是,當我嘗試在 Vercel 上部署項目時,出現以下錯誤:

Error: Cannot convert undefined or null to object

完整的日志是:

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

這是我的 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"
      }
}

該項目沒有 index.js 文件,似乎在嘗試編譯 index.js 時拋出錯誤。 我只是想部署一個代理,這樣我就可以從客戶端使用某個 API 而不是構建一個完整的后端。

當我運行“npm start”在本地運行它時,我沒有任何問題,我可以使用該項目。

我該如何解決這個問題?

我解決了這個問題,而不是使用“@now/node-server”,它應該是“@vercel/node”。 前者已棄用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM