如何在 Vercel 中使用 json-server mocha 上传前端项目?

问题描述

我有一个Angular 制作的项目和一个json-server 制作的简单模拟,我想知道除了运行前端,运行 json-server 之外,我如何制作 vercel,是吗?可能吗?

该项目已在 vercel 部署,但我无法让它运行 yarn start_backend 命令,因此后端可以使用模拟。

package.json

"scripts": {
    "start_backend": "json-server --watch --port 4300 db.json","ng": "ng","start": "ng serve","build": "ng build","test": "ng test","lint": "ng lint","e2e": "ng e2e"
}

json-sever.json

{
    "port": 4300,"delay": 200
}

db.json

{
  "users": [
    {
      "id": "0f1f30df-aa71-4c49-bb5f-aa71c689a432","full_name": "THIAGO DE BONIS","avatar": "assets/images/users/thiago.jpg","isMain": true,"isClicked": false
    },{
      "id": "cd7a7081-8d00-4156-98fb-ae0410532b37","full_name": "BILL GATES","avatar": "assets/images/users/bill.jpg","isMain": false,{
      "id": "aba7beca-0ffa-4057-8e45-fb65ea11d4a0","full_name": "MARGARET HAMILTON","avatar": "assets/images/users/margaret.jpg",{
      "id": "75d5a93f-25a3-44b8-a00c-9ec540e7269d","full_name": "STEVE JOBS","avatar": "assets/images/users/steve.jpg",{
      "id": "d4918415-f2db-438a-9ecd-61cd504d626c","full_name": "nikola TESLA","avatar": "assets/images/users/tesla.jpg",{
      "id": "d564173f-bd44-41c5-95a9-4c0f3088271b","full_name": "LINUS TORVALDS","avatar": "assets/images/users/linus.jpg",{
      "id": "85afbbab-d675-49b0-bbfe-c7903018c65b","full_name": "EDSGER DIJKSTRA","avatar": "assets/images/users/dijkstra.jpg","isClicked": true
    },{
      "id": "758474b4-0ac4-46be-81a4-bf7f14a6b740","full_name": "WARREN BUFFETT","avatar": "assets/images/users/warren.jpg",{
      "id": "be1044ec-4e0b-4bab-86ac-87ca7dce7bc2","full_name": "JACK MA","avatar": "assets/images/users/jack.jpg",{
      "id": "cbfe2ee3-6a4d-4c00-9206-f59694e31c30","full_name": "MARK ZUCKERBERG","avatar": "assets/images/users/mark.jpg","isClicked": false
    }
  ],"chat": [
    {
      "id": "cd7a7081-8d00-4156-98fb-ae0410532b37","messages": [
        {
          "id": "9f5da669-c6a4-4be2-8ad3-8f29058efbea","text": "Try once,twice,three times and if possible try the fourth,fifth and as many times as necessary.Just don't give up in the first few attempts,persistence is a friend of conquest. If you want to get to where the majority doesn't,do what the majority don't.","time": "2020-06-16T18:06:00.000Z","isRead": false
        }
      ]
    },"messages": [
        {
          "id": "8e19f8fe-d5b6-424a-a8bf-6b9538f5de49","text": "?? I'm the programmer who put the rocket on the moon,how about you? What have you done for humanity?","time": "2020-06-16T18:16:00.000Z","messages": [
        {
          "id": "de89e189-138f-4e3a-bb20-6124feceb576","text": "To be successful,it is necessary to truly love what you do. Otherwise,taking into account only the rational side,you simply give up. This is what happens to most people.","time": "2020-06-16T18:46:00.000Z","isRead": true
        }
      ]
    },"messages": [
        {
          "id": "0388a61b-d361-47b3-aaa5-59363f51785d","text": "Human development depends fundamentally on invention. It is the most important product of your creative brain. Its ultimate goal is the complete mastery of the mind over the material world and the use of the forces of nature in favor of human needs.","time": "2020-06-16T18:18:00.000Z","messages": [
        {
          "id": "ce980f6e-5b9c-4edb-b8ea-cd3d45f83fb8","text": "Talking is easy,show me the code.","time": "2020-06-16T18:03:00.000Z","messages": [
        {
          "id": "08377c54-4843-48c1-9b48-28ab8d586a8d","text": "Program testing can be a very effective way to demonstrate the presence of errors,but it is hopelessly insufficient to show its absence.","time": "2020-06-16T19:06:00.000Z","messages": [
        {
          "id": "57bf6d07-7490-4c8f-bf30-57d954038e8d","text": "Most people are interested in actions when everyone is interested. The time to be interested is when no one else is interested. You don't make money buying what is popular.","time": "2020-06-16T18:05:00.000Z","messages": [
        {
          "id": "a1c563c3-1965-463f-bce5-fc01baf16c5a","text": "The world won't remember what you say,but it certainly won't forget what you did.","time": "2020-06-16T18:04:00.000Z","messages": [
        {
          "id": "d9c2b42e-c6da-4de7-9aeb-0686b5685ed1","text": "In a world where changes are taking place quickly,the only strategy that will guarantee failure is to not take risks.","time": "2020-06-16T18:01:00.000Z","isRead": false
        }
      ]
    }
  ]
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...