Hello,
I face an issue with ghost 5.75.1 while trying to build docker image with my ghost-archive built from source. I clone official repo with source code, then execute:
$: yarn install
$: yarn archive
I take official Dockerfile for Ghost, change its contents slightly (just copy the archive into image and use --archive $ARCHIVE_NAME in the installation line).
I don’t make any changes into the repo for the sake of pure testing. Nevertheless, I am getting the following error:
Summary
#10 323.6 [5/5] Rebuilding all packages...
#10 326.3 error /var/lib/ghost/versions/5.75.1/node_modules/sqlite3: Command failed.
#10 326.3 Exit code: 1
#10 326.3 Command: node-pre-gyp install --fallback-to-build
#10 326.3 Arguments:
#10 326.3 Directory: /var/lib/ghost/versions/5.75.1/node_modules/sqlite3
#10 326.3 Output:
#10 326.3 /var/lib/ghost/versions/5.75.1/node_modules/wide-align/align.js:2
#10 326.3 var stringWidth = require('string-width')
#10 326.3 ^
#10 326.3
#10 326.3 Error [ERR_REQUIRE_ESM]: require() of ES Module /var/lib/ghost/versions/5.75.1/node_modules/string-width/index.js from /var/lib/ghost/versions/5.75.1/node_modules/wide-align/align.js not supported.
#10 326.3 Instead change the require of index.js in /var/lib/ghost/versions/5.75.1/node_modules/wide-align/align.js to a dynamic import() which is available in all CommonJS modules.
#10 326.3 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/wide-align/align.js:2:19)
#10 326.3 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/gauge/render-template.js:2:13)
#10 326.3 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/gauge/plumbing.js:3:22)
#10 326.3 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/gauge/index.js:2:16)
#10 326.3 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/npmlog/log.js:3:13)
#10 326.3 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js:23:13)
#10 326.3 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/@mapbox/node-pre-gyp/lib/main.js:9:22)
#10 326.3 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/@mapbox/node-pre-gyp/bin/node-pre-gyp:4:1) {
#10 326.3 code: 'ERR_REQUIRE_ESM'
#10 326.3 }
#10 326.3
#10 326.3 Node.js v18.19.0
#10 326.3 info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
#10 326.9 warning Error running install script for optional dependency: "/var/lib/ghost/versions/5.75.1/node_modules/@contrast/fn-inspect: Command failed.
#10 326.9 Exit code: 1
#10 326.9 Command: node-gyp-build
#10 326.9 Arguments:
#10 326.9 Directory: /var/lib/ghost/versions/5.75.1/node_modules/@contrast/fn-inspect
#10 326.9 Output:
#10 326.9 /var/lib/ghost/versions/5.75.1/node_modules/wide-align/align.js:2
#10 326.9 var stringWidth = require('string-width')
#10 326.9 ^
#10 326.9
#10 326.9 Error [ERR_REQUIRE_ESM]: require() of ES Module /var/lib/ghost/versions/5.75.1/node_modules/string-width/index.js from /var/lib/ghost/versions/5.75.1/node_modules/wide-align/align.js not supported.
#10 326.9 Instead change the require of index.js in /var/lib/ghost/versions/5.75.1/node_modules/wide-align/align.js to a dynamic import() which is available in all CommonJS modules.
#10 326.9 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/wide-align/align.js:2:19)
#10 326.9 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/node-gyp/node_modules/gauge/lib/render-template.js:2:13)
#10 326.9 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/node-gyp/node_modules/gauge/lib/plumbing.js:3:22)
#10 326.9 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/node-gyp/node_modules/gauge/lib/index.js:2:16)
#10 326.9 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/node-gyp/node_modules/npmlog/lib/log.js:3:13)
#10 326.9 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/node-gyp/lib/node-gyp.js:5:13)
#10 326.9 at Object.<anonymous> (/var/lib/ghost/versions/5.75.1/node_modules/node-gyp/bin/node-gyp.js:8:13) {
#10 326.9 code: 'ERR_REQUIRE_ESM'
#10 326.9 }
#10 326.9
#10 326.9 Node.js v18.19.0"
Node Version: v18.19.0
Ghost-CLI Version: 1.25.3
Yarn Version: 1.21.19
NPM Version: 10.2.3
I have tried to update npm to the latest version, nvm to 18.19.0 (18-lts), to use yarn 3 (not recommended by ghost code owners tho), to delete yarn.lock file, switch between debian/alpine official image - nothing works.
What am I doing wrong? Any additional steps required while building archive?
I am quite frustrated as I have been trying to build the image for quite a long time…
Any help would be highly appreciated.