簡體   English   中英

在 DigitalOean 上部署時解決節點版本錯誤

[英]Resolving Node version error while deployin on DigitalOean

我正在嘗試將我的應用程序從 github 部署到DigitalOcean應用程序服務器,但構建失敗。 構建日志如下:

[2022-12-05 11:33:05] ╭──────────── git repo clone ───────────╼
[2022-12-05 11:33:05] │  › fetching app source code
[2022-12-05 11:33:05] │ => Selecting branch "master"
[2022-12-05 11:33:06] │ => Checking out commit "079ec218fe19fe3c2f73cce87cf61776e1f50dfa"
[2022-12-05 11:33:06] │ 
[2022-12-05 11:33:06] │  ✔ cloned repo to /workspace
[2022-12-05 11:33:07] ╰────────────────────────────────────────╼
[2022-12-05 11:33:07] 
[2022-12-05 11:33:07]  › configuring build-time app environment variables:
[2022-12-05 11:33:07]      KBOARDS_APP_KEY LOCAL_BASE_URL
[2022-12-05 11:33:07] 
[2022-12-05 11:33:07]  › configuring custom build command to be run at the end of the build:
[2022-12-05 11:33:07]    │ npm run build
[2022-12-05 11:33:07] 
[2022-12-05 11:33:07] ╭──────────── buildpack detection ───────────╼
[2022-12-05 11:33:08] │ Detected the following buildpacks suitable to build your app:
[2022-12-05 11:33:08] │ 
[2022-12-05 11:33:08] │    heroku/nodejs-engine   v0.5.1  
[2022-12-05 11:33:08] │    digitalocean/node      v0.3.4  (Node.js)
[2022-12-05 11:33:08] │    digitalocean/procfile  v0.0.3  (Procfile)
[2022-12-05 11:33:08] │    digitalocean/custom    v0.1.1  (Custom Build Command)
[2022-12-05 11:33:08] │ 
[2022-12-05 11:33:08] │ For documentation on the buildpacks used to build your app, please see:
[2022-12-05 11:33:08] │ 
[2022-12-05 11:33:08] │    Node.js  v0.3.4  https://do.co/apps-buildpack-node
[2022-12-05 11:33:08] ╰─────────────────────────────────────────────╼
[2022-12-05 11:33:08] 
[2022-12-05 11:33:08] ╭──────────── app build ───────────╼
[2022-12-05 11:33:09] │ ---> Node.js Buildpack
[2022-12-05 11:33:09] │ ---> Installing toolbox
[2022-12-05 11:33:09] │ ---> - jq
[2022-12-05 11:33:09] │ ---> - yj
[2022-12-05 11:33:09] │ ---> Getting Node version
[2022-12-05 11:33:09] │ ---> Resolving Node version
[2022-12-05 11:33:10] │ ERROR: failed to build: exit status 1
[2022-12-05 11:33:11] │ 
[2022-12-05 11:33:11] │ 
[2022-12-05 11:33:11] │ For documentation on the buildpacks used to build your app, please see:
[2022-12-05 11:33:11] │ 
[2022-12-05 11:33:11] │    Node.js  v0.3.4  https://do.co/apps-buildpack-node
[2022-12-05 11:33:11] │ 
[2022-12-05 11:33:11] │  ✘ build failed

在 package.json 中,我有以下聲明:

  "version":"0.0.0",
  "engines": {
    "node": "^18.6.0",
    "npm": "^8.14.0"
  },

DigitalOcean 應用拓撲如下:

databases:
- engine: PG
  name: kbdb
  num_nodes: 1
  size: professional-xs
  version: "12"
envs:
- key: LOCAL_BASE_URL
  scope: RUN_AND_BUILD_TIME
  value: ${APP_URL}
name: kboards-staging
region: fra
services:
- build_command: npm run build
  environment_slug: node-js
  envs:
  - key: DATABASE_URL
    scope: RUN_TIME
    value: ${kbdb.DATABASE_URL}
  github:
    branch: master
    repo: zpiecuch81/kBoards
  http_port: 8080
  instance_count: 1
  instance_size_slug: professional-s
  name: kboards
  routes:
  - path: /
  run_command: npm start
  source_dir: /

描述ERROR: failed to build: exit status 1對我幫助不大。 我不知道為什么它不起作用。 它在本地運行時有效,部署到 Heroku 服務器時也能正常運行。 任何提示這可能是什么來源? 有人遇到過這樣的問題嗎?

順便說一句:我已經嘗試在 DigitalOcean 社區問題頁面上發布這個問題 3 次,但它看起來總是已發布,而且我以后再也找不到它了:(

結果是,DigitalOcean 還不支持 NodeJS 18,這是導致問題的原因:(

目前只有 NodeJS 14 和 16。

編輯:

這是關於此的更多信息: https://docs.digitalocean.com/products/app-platform/reference/buildpacks/nodejs/

只需在您的節點應用程序的package.json中指定這樣"engines": { "node": "16.x"},"engines": { "node": "14.x"},

暫無
暫無

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

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