puppeteer raises SyntaxError: Invalid regular expression when build docker

Viewed 747

when I running project on laptop, everything works normally but when i build image docker and run i give error please help me my laptop use node 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)

this is my dockerfile. I just installed some fake stuff and ran node server

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" ]

1 Answers

I have solved the similiar issue by upgrade node to the latest version.

For now, just change

FROM node:12-alpine AS BUILD_IMAGE

to

FROM node:17-alpine AS BUILD_IMAGE
Related