highcharts / node-export-server

Highcharts Node.js export server
Other
354 stars 260 forks source link

Error: ENOENT: no such file or directory, open '/app/dist//../templates/template.html' #520

Open develtype opened 3 months ago

develtype commented 3 months ago

Expected behaviour

running successfully

Actual behaviour

Error: ENOENT: no such file or directory, open '/app/dist//../templates/template.html'
    at Object.openSync (node:fs:600:3)
    at Object.readFileSync (node:fs:468:35)
    at 31415 (/app/dist/server.min.js:612785:20589)
    at __webpack_require__ (/app/dist/server.min.js:649632:42)
    at 92448 (/app/dist/server.min.js:313917:18)
    at __webpack_require__ (/app/dist/server.min.js:649632:42)
    at 49719 (/app/dist/server.min.js:314180:22)
    at __webpack_require__ (/app/dist/server.min.js:649632:42)
    at 48862 (/app/dist/server.min.js:313550:29)
    at __webpack_require__ (/app/dist/server.min.js:649632:42)
    at 66611 (/app/dist/server.min.js:304200:16)
    at __webpack_require__ (/app/dist/server.min.js:649632:42)
    at 80341 (/app/dist/server.min.js:313367:18)
    at __webpack_require__ (/app/dist/server.min.js:649632:42)
    at /app/dist/server.min.js:649729:37
    at Object.<anonymous> (/app/dist/server.min.js:649731:12) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/app/dist//../templates/template.html'
}

Reproduction steps

  1. install module in app
    yarn add highcharts-export-server
  2. build app and bundling to server.min.js
  3. run server.min.js
  4. see error.

dockerfile setting

FROM node:18.12.1-alpine3.15 as base

RUN apk add --no-cache \
    chromium

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
    PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

FROM base as builder
WORKDIR /app
COPY .npmrc package.json yarn.lock ./
RUN yarn --non-interactive
COPY . .

## Build backend
RUN yarn build

FROM base

WORKDIR /app
COPY --from=builder app/build dist

RUN npm install pm2 -g
EXPOSE $PORT

CMD ["pm2-runtime", "dist/server.min.js"]

when i run in dev env with node_modues, it works well. dev dockerfile

FROM node:18.12.1-alpine3.15 as base

RUN apk add --no-cache \
    chromium

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
    PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

WORKDIR /app
COPY .npmrc package.json yarn.lock tsconfig.json ./
RUN yarn --non-interactive

CMD ["npx", "ts-node-dev", "--inspect", "-r", "tsconfig-paths/register", "./src/index.ts"]

is bundling(building) with highcharts-export-server not available? should i set the highcharts-export-server to stand alone outside the BE app?

jszuminski commented 3 months ago

Thanks for reporting @develtype!


Internal note: related to this issue: https://github.com/highcharts/node-export-server/issues/348