Vite 构建冻结在 dokku 上的转换...

问题描述 投票:0回答:1

我有一个 Vite 应用程序,

vite build
在本地运行良好,并且在 digitalocean Paas 上构建成功。但是当我尝试在 dukku 上构建相同的应用程序时,它卡在了
transforming...

remote: -----> Cleaning up...        
remote: -----> Building app from herokuish        
remote: -----> Adding BUILD_ENV to build environment...        
remote:        BUILD_ENV added successfully        
remote:        -----> Node.js app detected        
remote:                
remote: -----> Creating runtime environment        
remote:                
remote:        NPM_CONFIG_LOGLEVEL=error        
remote:        NODE_VERBOSE=false        
remote:        NODE_ENV=production        
remote:        NODE_MODULES_CACHE=true        
remote:                
remote: -----> Installing binaries        
remote:        engines.node (package.json):  unspecified        
remote:        engines.npm (package.json):   unspecified (use default)        
remote:                
remote:        Resolving node version 20.x...        
remote:        Downloading and installing node 20.11.0...        
remote:        Using default npm version: 10.2.4        
remote:                
remote: -----> Installing dependencies        
remote:        Installing node modules        
remote:                
remote:        added 786 packages, and audited 787 packages in 38s        
remote:                
remote:        144 packages are looking for funding        
remote:        run `npm fund` for details        
remote:                
remote:        42 vulnerabilities (37 moderate, 5 high)        
remote:                
remote:        To address issues that do not require attention, run:        
remote:        npm audit fix        
remote:                
remote:        Some issues need review, and may require choosing        
remote:        a different dependency.        
remote:                
remote:        Run `npm audit` for details.        
remote:        npm notice        
remote:        npm notice New minor version of npm available! 10.2.4 -> 10.5.0        
remote:        npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.5.0>        
remote:        npm notice Run `npm install -g [email protected]` to update!        
remote:        npm notice        
remote:                
remote: -----> Build        
remote:        Running build        
remote:                
remote:        > [email protected] build        
remote:        > run-p type-check build:only        
remote:                
remote:                
remote:        > [email protected] type-check        
remote:        > vue-tsc --noEmit        
remote:                
remote:                
remote:        > [email protected] build:only        
remote:        > vite build        
remote:                
remote:        vite v4.5.0 building for production...        
remote:        transforming...        
remote: Killed        
remote: ERROR: "type-check" exited with 137.        
remote:                
remote: -----> Build failed        
remote:                
remote:        We're sorry this build is failing! You can troubleshoot common issues here:        
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys        
remote:                
remote:        Some possible problems:        
remote:                
remote:        - Node version not specified in package.json        
remote:        https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version        
remote:                
remote:        Love,        
remote:        Heroku        
remote:                
remote:  !     Failure during app build        
remote:  !     Removing invalid image tag dokku/app:latest        
remote:  !     App build failed
vite dokku
1个回答
0
投票

您看到的

Killed
消息可能是由于构建期间内存不足造成的。 PaaS 的构建服务器通常比运行环境拥有更多的可用内存,而 Nodejs 有时特别需要内存。

您可以:

  • 配置具有更多内存的服务器
  • 添加交换空间

来自 dokku 文档,以下是向服务器添加 2GB 交换空间的方法:

sudo install -o root -g root -m 0600 /dev/null /swapfile
dd if=/dev/zero of=/swapfile bs=1k count=2048k
mkswap /swapfile
swapon /swapfile
echo "/swapfile       swap    swap    auto      0       0" | sudo tee -a /etc/fstab
sudo sysctl -w vm.swappiness=10
echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf

请注意,设置交换内存会牺牲磁盘空间,速度可能会变慢,并且也会更快地磨损磁盘。也就是说,它是“免费的”,您可以避免在此期间支付更多的内存费用。

© www.soinside.com 2019 - 2024. All rights reserved.