nuxt.js项目如何部署到服务器?

项目打包

  1. yarn build或者npm build

需要上传的文件

1. .nuxt目录

2. package.json

3. nuxt.config.js

4. static

5. server目录 (不传会报错ERROR Renderer is loaded but not all resources are unavailable! Please check /www/wwwroot/sanwei/.nuxt/dist/server existence.)

项目打包后上传到OSS

1.需要创建一个deploy.js

 
  1. const OSS = require("ali-oss");
  2. const fs = require("fs");
  3. const path = require("path");
  4. const os = require("os");
  5. const PUBLIC_PATH = path.join(__dirname, "/");
  6. //需要替换成自己的
  7. const client = new OSS({
  8. region: 'oss的地理位置',
  9. accessKeyId: ' accessKeyId',
  10. accessKeySecret: ' accessKeySecret',
  11. bucket: 'bucket名字'
  12. })
  13.  
  14. /**
  15. *获取文件目录并删除
  16. * @param {*} dir //文件目录
  17. */
  18. async function deleteDir(dir) {
  19. let result = await client.list({
  20. prefix: dir + "/",
  21. delimiter: "/"
  22. });
  23. if (result.objects) {
  24. let aa = [];
  25. result.objects.forEach(function (obj) {
  26. aa.push(obj.name);
  27. });
  28. try {
  29. await client.deleteMulti(aa, {
  30. quiet: true
  31. });
  32. consol
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值