这个问题
只有在使用木偶师添加新的云函数时才会引入。该错误仅在尝试将其推送到 Google Cloud 函数时才会在使用"firebase serve"的本地模式下发生。这个云函数是一个更大项目的开始,但我想测试我是否可以在直播前在本地做一些基础知识,这是我在页面底部的日志中收到的错误。
我尝试仅使用(应用程序(导出 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:Usersbradley_chtoolsnode-v10.15.1-win-x64node_modulesnpmnode_modulesnpm-lifecyclenode-gyp-bin;C:Usersbradley_chOneDriveProductionBenchmarkingreactAppfunctionsnode_modules.bin;C:Program Files (x86)RSA SecurID Token Common;c:Oracle11ginstantclient_11_2;C:ProgramDataOracleJavajavapath;C:windowssystem32;C:windows;C:windowsSystem32Wbem;C:windowsSystem32WindowsPowerShellv1.0;C:Program Files (x86)SybaseSharedPowerBuilder;C:Usersbradley_chAppDataLocalProgramsPythonPython37-32Scripts;C:Usersbradley_chAppDataLocalProgramsPythonPython37-32;C:Usersbradley_chAppDataLocalProgramsPythonLauncher;C:Usersbradley_chAppDataLocalMicrosoftWindowsApps;C:Usersbradley_chAppDataLocalProgramsMicrosoft VS Codebin;C:Usersbradley_chtoolsnode-v10.15.1-win-x64;C:Usersbradley_chDesktopCasperbin;C:Usersbradley_chAppDataLocalProgramsGitcmd
9 verbose lifecycle functions@~lint: CWD: C:Usersbradley_chOneDriveProductionBenchmarkingreactAppfunctions
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:Usersbradley_chtoolsnode-v10.15.1-win-x64node_modulesnpmnode_modulesnpm-lifecycleindex.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:189:13)
13 verbose stack at ChildProcess.<anonymous> (C:Usersbradley_chtoolsnode-v10.15.1-win-x64node_modulesnpmnode_modulesnpm-lifecyclelibspawn.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:Usersbradley_chOneDriveProductionBenchmarkingreactApp
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%
。