使用render.com时遇到以下错误:
==\> Running 'node index.js'
Oct 8 07:57:38 PM /opt/render/project/src/node_modules/puppeteer-core/lib/cjs/puppeteer/util/disposable.js:19
Oct 8 07:57:38 PM Symbol.dispose ??= Symbol('dispose');
Oct 8 07:57:38 PM ^^^
Oct 8 07:57:38 PM
Oct 8 07:57:38 PM SyntaxError: Unexpected token '??='
Oct 8 07:57:38 PM at wrapSafe (internal/modules/cjs/loader.js:984:16)
Oct 8 07:57:38 PM at Module.\_compile (internal/modules/cjs/loader.js:1032:27)
Oct 8 07:57:38 PM at Object.Module.\_extensions..js (internal/modules/cjs/loader.js:1097:10)
Oct 8 07:57:38 PM at Module.load (internal/modules/cjs/loader.js:933:32)
Oct 8 07:57:38 PM at Function.Module.\_load (internal/modules/cjs/loader.js:774:14)
Oct 8 07:57:38 PM at Module.require (internal/modules/cjs/loader.js:957:19)
Oct 8 07:57:38 PM at require (internal/modules/cjs/helpers.js:88:18)
Oct 8 07:57:38 PM at Object.\<anonymous\> (/opt/render/project/src/node_modules/puppeteer-core/lib/cjs/puppeteer/common/EventEmitter.js:23:25)
Oct 8 07:57:38 PM at Module.\_compile (internal/modules/cjs/loader.js:1068:30)
我的index.js代码是:
const express = require("express");
const {sl} = require("./sl");
const app = express();
const PORT = process.env.PORT || 4000;
app.get("/scrape", (req, res) => {
sl(res);
})
app.get("/", (req, res) => {
res.send("Render Puppeteer server is up and running!");
})
app.listen(4000, () => {
console.log(`Listening on port ${PORT}`)
})
我的ScrapeLoading代码是:
const express = require("express");
const {sl} = require("./sl");
const app = express();
const PORT = process.env.PORT || 4000;
app.get("/scrape", (req, res) => {
sl(res);
})
app.get("/", (req, res) => {
res.send("Render Puppeteer server is up and running!");
})
app.listen(4000, () => {
console.log(`Listening on port ${PORT}`)
})
另外,我已经更新了puppeteer和node.js
1条答案
按热度按时间gv8xihay1#
符号。处理掉??= Symbol('dispose');^^^
语法错误:意外的信物??='
我在Node.js Web应用程序中使用Puppeteer下载PDF时遇到错误。这似乎是一个语法错误,我花了很多时间查看我的代码来确定问题。最终,我发现这个问题与我的“Node.js版本不是最新的”有关。Puppeteer不支持我正在使用的版本。一旦我更新了我的Node.js和Puppeteer,这个问题就解决了。