【问题标题】:puppeteer raises SyntaxError: Invalid regular expression when build dockerpuppeteer 引发 SyntaxError: Invalid regular expression when build docker
【发布时间】:2022-01-09 18:35:09
【问题描述】:

当我在笔记本电脑上运行项目时,一切正常 但是当我构建图像 docker 并运行时我给出错误请帮助我 我的笔记本电脑使用节点 12

/var/www/html/jardinsgmc/node_modules/puppeteer/lib/cjs/puppeteer/common/AriaQueryHandler.js:30
const attributeRegexp = /\[\s*(?<attribute>\w+)\s*=\s*"(?<value>\\.|[^"\\]*)"\s*\]/g;
                        ^

SyntaxError: Invalid regular expression: /\[\s*(?<attribute>\w+)\s*=\s*"(?<value>\\.|[^"\\]*)"\s*\]/: Invalid group
    at Object.<anonymous> (/var/www/html/jardinsgmc/node_modules/puppeteer/lib/cjs/puppeteer/common/AriaQueryHandler.js:30:25)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/var/www/html/jardinsgmc/node_modules/puppeteer/lib/cjs/puppeteer/common/QueryHandler.js:19:31)
    at Module._compile (module.js:653:30)

这是我的 dockerfile。我刚刚安装了一些假的东西并运行了节点服务器

FROM node:12-alpine AS BUILD_IMAGE
RUN apk update && apk add python3 py3-pip make g++ && rm -rf /var/cache/apk/*
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
FROM ubuntu:18.04
WORKDIR /usr/src/app

COPY . .
COPY --from=BUILD_IMAGE /usr/src/app/node_modules ./node_modules

RUN apt-get update
RUN  yes | apt-get install apt-utils
RUN yes | apt-get install ffmpeg
RUN yes | apt-get install nodejs

EXPOSE 8082
CMD [ "node", "server.js" ]

【问题讨论】:

    标签: docker puppeteer


    【解决方案1】:

    我已经通过升级节点到最新版本解决了类似的问题。

    现在,只需改变

    FROM node:12-alpine AS BUILD_IMAGE
    

    FROM node:17-alpine AS BUILD_IMAGE
    

    【讨论】:

      猜你喜欢
      • 2021-02-02
      • 2015-09-22
      • 1970-01-01
      • 1970-01-01
      • 2022-06-28
      • 2020-02-04
      • 2020-02-19
      • 2022-12-02
      • 1970-01-01
      相关资源
      最近更新 更多