gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 19:39:09 24 4
gpt4 key购买 nike

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

我尝试仅使用 (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 npm@6.4.1
3 info using node@v10.15.1
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 ]

最佳答案

12 info lifecycle functions@~lint: Failed to exec lint script
13 verbose stack Error: functions@ lint: `eslint .`

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

安装它,使用绝对路径或让您的应用程序遵守 %PATH%

关于javascript - 无法部署谷歌云功能(错误 : ELIFECYCLE),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55592804/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com