vue3 打包时报错

(env) [root@VM-20-16-centos vue3shower]# npm run build

> vue3shower@0.1.0 build
> vue-cli-service build

All browser targets in the browserslist configuration have supported ES module.
Therefore we don't build two separate bundles for differential loading.


⠴  Building for production...Killed

环境是centos (垃圾)云主机

原因:

内存不够了

解决办法:

(env) [root@VM-20-16-centos vue3shower]# sudo fallocate -l 4G /swapfile
(env) [root@VM-20-16-centos vue3shower]# ll /s
sbin/     srv/      swapfile  sys/      
(env) [root@VM-20-16-centos vue3shower]# ll /s
sbin/     srv/      swapfile  sys/      
(env) [root@VM-20-16-centos vue3shower]# ll /swapfile 
-rw-r--r-- 1 root root 4294967296 May  2 00:11 /swapfile
(env) [root@VM-20-16-centos vue3shower]# ls -lh /swapfile
-rw-r--r-- 1 root root 4.0G May  2 00:11 /swapfile
(env) [root@VM-20-16-centos vue3shower]# sudo chmod 600 /swapfile
(env) [root@VM-20-16-centos vue3shower]# sudo mkswap /swapfile
Setting up swapspace version 1, size = 4194300 KiB
no label, UUID=02f5d27d-c990-48db-883a-fc28a35cd391
(env) [root@VM-20-16-centos vue3shower]# sudo swapon /swapfile
(env) [root@VM-20-16-centos vue3shower]# sudo swapon -s
Filename                                Type            Size    Used    Priority
/swapfile                               file    4194300 0       -2
(env) [root@VM-20-16-centos vue3shower]# free -m
              total        used        free      shared  buff/cache   available
Mem:           3789        2652         865           0         271         912
Swap:          4095           0        4095
(env) [root@VM-20-16-centos vue3shower]# sudo vim /etc/fstab
(env) [root@VM-20-16-centos vue3shower]# 
(env) [root@VM-20-16-centos vue3shower]# 
(env) [root@VM-20-16-centos vue3shower]# npm run build

说明:

运行:

 sudo fallocate -l 4G /swapfile;

ls -lh /swapfile;

sudo chmod 600 /swapfile;

sudo mkswap /swapfile;

sudo swapon /swapfile;

sudo swapon -s;

free -m;

然后运行:

 sudo vim /etc/fstab 

把下面语句加入/etc/fstab文件末尾

 /swapfile none swap sw 0 0

再执行npm run build就能成功了。

Logo

前往低代码交流专区

更多推荐