无法部署谷歌云功能(错误:ELIFECYCLE)

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

只有在使用puppeteer添加新的云功能时才会引入此问题。只有在尝试将其推送到谷歌云功能时,才会使用“firebase serve”在本地模式下出现错误。这个云功能是一个更大的项目的开始,但我想测试我是否可以在现场之前在本地执行基础知识,这是我在页面底部的日志中收到的错误。

我已经尝试使用just(app)导出api路由,然后创建一个必需的路径。

const functions = require('firebase-functions');
const app = require('express')();
const puppeteer = require('puppeteer');

const { benchmark } = require('./handlers/benchmark');

// Runs before every route. Launches headless Chrome.
app.all('*', async (req, res, next) => {
    // Note: --no-sandbox is required in this env.
    // Could also launch chrome and reuse the instance
    // using puppeteer.connect()
    res.locals.browser = await puppeteer.launch({
        args: ['--no-sandbox']
    });
    next(); // pass control to next route.
});
// Handler to take screenshots of a URL.
app.get('/benchmark', benchmark);

// Tried this first
exports.api = functions.https.onRequest(app);
// Tried this second
exports.api = functions.https.onRequest((req, res) => {
    if (!req.path) {
        req.url = `/${req.url}`;
    }
    return app(req, res);
});

我的基准文件:

exports.benchmark = async function screenshotHandler(req, res) {
    // const url = '/';
    // req.query.url
    // if (!url) {
    //  return res
    //      .status(400)
    //      .send('Please provide a URL. Example: ?url=https://example.com');
    // }
    const browser = res.locals.browser;
    try {
        const page = await browser.newPage();
        await page.goto('https://www.google.com', {
            waitUntil: 'networkidle2'
        });;
        const buffer = await page.screenshot({ fullPage: true });
        await res.type('image/png').send(buffer);
    } catch (e) {
        res.status(500).send(e.toString());
    }
    await browser.close();
};

日志:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Users\\bradley_ch\\tools\\node-v10.15.1-win-x64\\node.exe',
1 verbose cli   'C:\\Users\\bradley_ch\\tools\\node-v10.15.1-win-x64\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   '--prefix',
1 verbose cli   'C:\\Users\\bradley_ch\\OneDrive\\Production\\Benchmarking\\reactApp\\functions',
1 verbose cli   'run',
1 verbose cli   'lint' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions@~prelint: functions@
6 info lifecycle functions@~lint: functions@
7 verbose lifecycle functions@~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions@~lint: PATH: C:\Users\bradley_ch\tools\node-v10.15.1-win-x64\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\bradley_ch\OneDrive\Production\Benchmarking\reactApp\functions\node_modules\.bin;C:\Program Files (x86)\RSA SecurID Token Common;c:\Oracle11g\instantclient_11_2;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Sybase\Shared\PowerBuilder\;C:\Users\bradley_ch\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\bradley_ch\AppData\Local\Programs\Python\Python37-32\;C:\Users\bradley_ch\AppData\Local\Programs\Python\Launcher\;C:\Users\bradley_ch\AppData\Local\Microsoft\WindowsApps;C:\Users\bradley_ch\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\bradley_ch\tools\node-v10.15.1-win-x64;C:\Users\bradley_ch\Desktop\Casper\bin;C:\Users\bradley_ch\AppData\Local\Programs\Git\cmd
9 verbose lifecycle functions@~lint: CWD: C:\Users\bradley_ch\OneDrive\Production\Benchmarking\reactApp\functions
10 silly lifecycle functions@~lint: Args: [ '/d /s /c', 'eslint .' ]
11 silly lifecycle functions@~lint: Returned: code: 1  signal: null
12 info lifecycle functions@~lint: Failed to exec lint script
13 verbose stack Error: functions@ lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\bradley_ch\tools\node-v10.15.1-win-x64\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:189:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\bradley_ch\tools\node-v10.15.1-win-x64\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:189:13)
13 verbose stack     at maybeClose (internal/child_process.js:970:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid functions@
15 verbose cwd C:\Users\bradley_ch\OneDrive\Production\Benchmarking\reactApp
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\\Users\\bradley_ch\\tools\\node-v10.15.1-win-x64\\node.exe" "C:\\Users\\bradley_ch\\tools\\node-v10.15.1-win-x64\\node_modules\\npm\\bin\\npm-cli.js" "--prefix" "C:\\Users\\bradley_ch\\OneDrive\\Production\\Benchmarking\\reactApp\\functions" "run" "lint"
18 verbose node v10.15.1
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error functions@ lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions@ lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
javascript node.js firebase google-cloud-functions puppeteer
1个回答
1
投票
12 info lifecycle functions@~lint: Failed to exec lint script
13 verbose stack Error: functions@ lint: `eslint .`

该系统没有或不知道eslint在哪里或是什么。

安装它,使用绝对路径或使您的应用程序尊重%PATH%

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