0

我遇到了 react-snap 的问题。react-snap 的最后一次更新是在 3 年前。它有点过时了。似乎 react-snap 未能在反应页面上抓取我的 pdf 文件。

这是产生的错误反应快照:

% docker build -t frontend-app:lastest .

...
...

> frontend@0.1.0 postbuild /app
> react-snap

✅  crawled 1 out of 3 (/)
⚠️  warning: 404 page title does not contain "404" string
✅  crawled 2 out of 3 (/404.html)
✅  crawled 3 out of 5 (/resume)
  error at /static/media/%E6%B1%9F%E6%B3%BD%E7%BE%A4-2021-%E5%89%8D%E7%AB%AF%E5%B7%A5%E7%A8%8B%E5%B8%88-cv.07917375.pdf Error: net::ERR_ABORTED at http://localhost:45678/static/media/%E6%B1%9F%E6%B3%BD%E7%BE%A4-2021-%E5%89%8D%E7%AB%AF%E5%B7%A5%E7%A8%8B%E5%B8%88-cv.07917375.pdf
    at navigate (/app/node_modules/puppeteer/lib/FrameManager.js:120:37)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async FrameManager.navigateFrame (/app/node_modules/puppeteer/lib/FrameManager.js:94:17)
    at async Frame.goto (/app/node_modules/puppeteer/lib/FrameManager.js:406:12)
    at async Page.goto (/app/node_modules/puppeteer/lib/Page.js:674:12)
    at async fetchPage (/app/node_modules/react-snap/src/puppeteer_utils.js:232:11)
  -- ASYNC --
    at Frame.<anonymous> (/app/node_modules/puppeteer/lib/helper.js:111:15)
    at Page.goto (/app/node_modules/puppeteer/lib/Page.js:674:49)
    at Page.<anonymous> (/app/node_modules/puppeteer/lib/helper.js:112:23)
    at fetchPage (/app/node_modules/react-snap/src/puppeteer_utils.js:232:22)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend@0.1.0 postbuild: `react-snap`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the frontend@0.1.0 postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-08-16T17_17_58_884Z-debug.log
The command '/bin/sh -c npm run build' returned a non-zero code: 1

当我尝试在 mhart/alpine-node:14 容器中构建我的 react-app 时,就会发生这种情况。

这是我的 Dockerfile:

FROM mhart/alpine-node:14
WORKDIR '/app'
RUN apk add --no-cache \
      chromium \
      nss \
      freetype \
      harfbuzz \
      ca-certificates \
      ttf-freefont \
      nodejs

ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

RUN npm i puppeteer-core
COPY package.json .
RUN npm install
COPY . .
RUN npm run build


FROM nginx
COPY --from=0 /app/build /usr/share/nginx/html
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
COPY ./nginx/ssl /etc/nginx/ssl

我在这里错过了什么?如果这个问题不能解决。react-snap 有其他选择吗?

4

0 回答 0