簡體   English   中英

Github 推送錯誤。 嘗試使用 git-lfs 跟蹤 puppeteer chromium 后仍然出現大文件錯誤。 為什么它甚至試圖上傳這個?

[英]Github push error. Getting large file errors still after trying to track puppeteer chromium with git-lfs. Why is it even trying to upload this?

我正在嘗試將使用 puppeteer2.1.1 的 Node.js 應用程序推送到 Github 中,這樣我就可以在 Azure 上進行托管。 嘗試推動后,我得到了這些錯誤。

嘗試推送到 git 后的錯誤消息

我嘗試使用git lfs通過跟蹤文件來跟蹤所有命令,根據錯誤消息,我認為這些文件需要是/.local-chromium 再次嘗試推送后仍然失敗。

有沒有人使用 puppeteer 並上傳到 GitHub 遇到過同樣的問題? 我也很困惑為什么它甚至會進入 node_modules 文件夾。 我認為推送到 git 時會自動忽略它。 下面是我的代碼。

index.js

const puppeteer = require("puppeteer");
require('dotenv').config();
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);
var schedule = require('node-schedule');

function coronaInfoSearch(){

    puppeteer.launch({  
        headless:true
    }).then(async browser =>{


        //open new tab and go to specified url
        const page = await browser.newPage();

        await page.goto('https://www.worldometers.info/coronavirus/country/us/');

        //select elements wanted 
        page.waitForSelector('td')
            .then(async function(){

                //var self explanatory 
                const njRowTotalCases =await page.$eval('table .even .sorting_1', element => element.innerHTML);
                const njRowName = await page.$eval('table .even td', element => element.innerHTML);
                const njRowActiveCases = await page.$eval('#usa_table_countries_today > tbody:nth-child(2) > tr:nth-child(2) > td:nth-child(6)', element => element.innerHTML);
                const njRowDeaths = await page.$eval('#usa_table_countries_today > tbody:nth-child(2) > tr:nth-child(2) > td:nth-child(4)' , element => element.innerHTML);

                var coronainfoOutput = "Total Cases:\n"+njRowTotalCases+"\n\n"+"Active Cases:"+njRowActiveCases+"\n\n"+"Total Deaths:"+njRowDeaths;
                //atring to be sent for outputting 
                var coronainfoOutputHeading="NJ COVID-19 Update\n----------------\n";

                //sent text message 
                client.messages
                  .create({
                     body: coronainfoOutputHeading + coronainfoOutput,
                     from: process.env.TWILIO_PHONE_NUMBER,
                     to: process.env.ANT_NUMBER
                   })
                  .then(message => console.log(message.sid));
            })
    });
};

schedule.scheduleJob("55 13 * * 0-6", function(){
    coronaInfoSearch();
});

package.json

{
  "name": "coronawebscrap",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "puppeteer":  "^2.1.1",
    "node-schedule": "^1.3.2",
    "twilio": "^3.41.1"
  }
}

.git 屬性

.local-chromium filter=lfs diff=lfs merge=lfs -text
node_modules/puppeteer/.local-chromium filter=lfs diff=lfs merge=lfs -text

編輯

將 node_modules/ 放在 .gitignore 文件下,然后添加到 git repo,然后提交,然后推送,我仍然有同樣的錯誤。

.gitignore

.env
node_modules/

Git 操作和錯誤:

**git 操作和錯誤**

您需要在存儲庫的根目錄中有一個.gitignore文件,因為您不想上傳 node_modules

看看: https://github.com/github/gitignore/blob/master/Node.gitignore

希望你得到幫助。 但是,作為另一個建議,

`git lfs track "*.zip"`

應該做的伎倆! 干杯! (按照( Git 大文件頁面)上的指南進行操作

暫無
暫無

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

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