我执行了下一页的代码。但是发生了错误。
我试图更改代码,但没有这样的文件或目录错误无法修复,也无法正常工作。
https://www.npmjs.com/package/puppeteer-to-istanbul
(node:18592) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'C:\Users\username\Desktop\.nyc_output\js\m=WgDvvc,aa,abd,async,dvl,fEVMic,foot,lu,m,mUpTid,mu,sb_wiz,sf,spch,xz7cCd?xjs=s1.js'
at Object.openSync (fs.js:443:3)
at Object.writeFileSync (fs.js:1194:35)
at OutputFiles._parseAndIsolate (C:\Users\username\node_modules\puppeteer-to-istanbul\lib\output-files.js:52:10)
at new OutputFiles (C:\Users\username\node_modules\puppeteer-to-istanbul\lib\output-files.js:18:10)
at module.exports (C:\Users\username\node_modules\puppeteer-to-istanbul\lib\output-files.js:62:10)
at new PuppeteerToIstanbul (C:\Users\username\node_modules\puppeteer-to-istanbul\lib\puppeteer-to-istanbul.js:10:33)
at module.exports (C:\Users\username\node_modules\puppeteer-to-istanbul\lib\puppeteer-to-istanbul.js:37:10)
at Object.write (C:\Users\username\node_modules\puppeteer-to-istanbul\index.js:5:17)
at C:\Users\username\Desktop\original.js:19:7
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:18592) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:18592) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(async () => {
const pti = require('puppeteer-to-istanbul')
const puppeteer = require('puppeteer')
const browser = await puppeteer.launch()
const page = await browser.newPage()
// Enable both JavaScript and CSS coverage
await Promise.all([
page.coverage.startJSCoverage(),
page.coverage.startCSSCoverage()
]);
// Navigate to page
await page.goto('https://www.google.com');
// Disable both JavaScript and CSS coverage
const [jsCoverage, cssCoverage] = await Promise.all([
page.coverage.stopJSCoverage(),
page.coverage.stopCSSCoverage(),
]);
pti.write(jsCoverage)
await browser.close()
})().catch(e => console.error(e))
{ Error: ENOENT: no such file or directory, open 'C:\Users\username\Desktop\.nyc_output\js\m=WgDvvc,aa,abd,async,dvl,fEVMic,foot,lu,m,mUpTid,mu,sb_wiz,sf,spch,xz7cCd?xjs=s1.js'
at Object.openSync (fs.js:443:3)
at Object.writeFileSync (fs.js:1194:35)
at OutputFiles._parseAndIsolate (C:\Users\username\node_modules\puppeteer-to-istanbul\lib\output-files.js:52:10)
at new OutputFiles (C:\Users\username\node_modules\puppeteer-to-istanbul\lib\output-files.js:18:10)
at module.exports (C:\Users\username\node_modules\puppeteer-to-istanbul\lib\output-files.js:62:10)
at new PuppeteerToIstanbul (C:\Users\username\node_modules\puppeteer-to-istanbul\lib\puppeteer-to-istanbul.js:10:33)
at module.exports (C:\Users\username\node_modules\puppeteer-to-istanbul\lib\puppeteer-to-istanbul.js:37:10)
at Object.write (C:\Users\username\node_modules\puppeteer-to-istanbul\index.js:5:17)
at C:\Users\username\Desktop\original_add_catch.js:19:7
at process._tickCallback (internal/process/next_tick.js:68:7)
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path:
'C:\\Users\\username\\Desktop\\.nyc_output\\js\\m=WgDvvc,aa,abd,async,dvl,fEVMic,foot,lu,m,mUpTid,mu,sb_wiz,sf,spch,xz7cCd?xjs=s1.js' }
(async () => {
const pti = require('puppeteer-to-istanbul')
const puppeteer = require('puppeteer')
const browser = await puppeteer.launch()
const page = await browser.newPage()
// Enable both JavaScript and CSS coverage
await page.coverage.startCSSCoverage()
// Navigate to page
await page.goto('https://www.google.com/');
// Disable both JavaScript and CSS coverage
const cssCoverage = await page.coverage.stopCSSCoverage();
pti.write(cssCoverage)
await browser.close()
})()