Skip to content

Canvas install failed in Docker image build from AWS CodeBuild #2547

@eddiechan0101

Description

@eddiechan0101

Getting error in docker image build.

Docker file

FROM node:22-alpine3.23

WORKDIR /server

# for npm canvas
RUN apk update && apk add build-base g++ cairo-dev pango-dev giflib-dev font-liberation 
RUN apk add --no-cache \
    libpng \
    libpng-dev \
    jpeg-dev

RUN yarn

The following error is returned

error /server/node_modules/canvas: Command failed.
--
Exit code: 1
Command: prebuild-install -r napi \|\| node-gyp rebuild
Arguments:
Directory: /server/node_modules/canvas
Output:
prebuild-install warn install No prebuilt binaries found (target=7 runtime=napi arch=x64 libc=musl platform=linux)
gyp info it worked if it ends with ok
gyp info using node-gyp@11.2.0
gyp info using node@22.21.1 \| linux \| x64
gyp info find Python using Python version 3.12.12 found at "/usr/bin/python3"
 
gyp http GET https://unofficial-builds.nodejs.org/download/release/v22.21.1/node-v22.21.1-headers.tar.gz
gyp http 200 https://unofficial-builds.nodejs.org/download/release/v22.21.1/node-v22.21.1-headers.tar.gz
gyp http GET https://unofficial-builds.nodejs.org/download/release/v22.21.1/SHASUMS256.txt
gyp http 200 https://unofficial-builds.nodejs.org/download/release/v22.21.1/SHASUMS256.txt
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/server/node_modules/canvas/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/root/.cache/node-gyp/22.21.1/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/22.21.1',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/22.21.1/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/server/node_modules/canvas',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/server/node_modules/canvas/build'
SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
COPY Release/canvas-postbuild.node
CXX(target) Release/obj.target/canvas/src/backend/Backend.o
CXX(target) Release/obj.target/canvas/src/backend/ImageBackend.o
CXX(target) Release/obj.target/canvas/src/backend/PdfBackend.o
CXX(target) Release/obj.target/canvas/src/backend/SvgBackend.o
CXX(target) Release/obj.target/canvas/src/bmp/BMPParser.o
CXX(target) Release/obj.target/canvas/src/Backends.o
CXX(target) Release/obj.target/canvas/src/Canvas.o
CXX(target) Release/obj.target/canvas/src/CanvasGradient.o
CXX(target) Release/obj.target/canvas/src/CanvasPattern.o
CXX(target) Release/obj.target/canvas/src/CanvasRenderingContext2d.o
CXX(target) Release/obj.target/canvas/src/closure.o
CXX(target) Release/obj.target/canvas/src/color.o
CXX(target) Release/obj.target/canvas/src/Image.o
CXX(target) Release/obj.target/canvas/src/ImageData.o
CXX(target) Release/obj.target/canvas/src/init.o
CXX(target) Release/obj.target/canvas/src/register_font.o
CXX(target) Release/obj.target/canvas/src/FontParser.o
In file included from ../src/FontParser.h:9,
from ../src/FontParser.cc:9:
../src/CharData.h:7:20: error: 'uint8_t' does not name a type
7 \|   static constexpr uint8_t Whitespace = 0x1;
\|                    ^~~~~~~
../src/CharData.h:1:1: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
+++ \|+#include <cstdint>
1 \| // This is used for classifying characters according to the definition of tokens
../src/CharData.h:8:20: error: 'uint8_t' does not name a type
8 \|   static constexpr uint8_t Newline = 0x2;
\|                    ^~~~~~~
../src/CharData.h:8:20: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/CharData.h:9:20: error: 'uint8_t' does not name a type
9 \|   static constexpr uint8_t Hex = 0x4;
\|                    ^~~~~~~
../src/CharData.h:9:20: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/CharData.h:10:20: error: 'uint8_t' does not name a type
10 \|   static constexpr uint8_t Nmstart = 0x8;
\|                    ^~~~~~~
../src/CharData.h:10:20: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/CharData.h:11:20: error: 'uint8_t' does not name a type
11 \|   static constexpr uint8_t Nmchar = 0x10;
\|                    ^~~~~~~
../src/CharData.h:11:20: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/CharData.h:12:20: error: 'uint8_t' does not name a type
12 \|   static constexpr uint8_t Sign = 0x20;
\|                    ^~~~~~~
../src/CharData.h:12:20: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/CharData.h:13:20: error: 'uint8_t' does not name a type
13 \|   static constexpr uint8_t Digit = 0x40;
\|                    ^~~~~~~
../src/CharData.h:13:20: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/CharData.h:14:20: error: 'uint8_t' does not name a type
14 \|   static constexpr uint8_t NumStart = 0x80;
\|                    ^~~~~~~
../src/CharData.h:14:20: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/CharData.h:19:17: error: 'uint8_t' does not name a type
19 \| constexpr const uint8_t charData[256] = {
\|                 ^~~~~~~
../src/CharData.h:19:17: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.h:25:3: error: 'uint16_t' does not name a type
25 \|   uint16_t fontWeight{400};
\|   ^~~~~~~~
../src/FontParser.h:10:1: note: 'uint16_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
9 \| #include "CharData.h"
+++ \|+#include <cstdint>
10 \|
../src/FontParser.h:68:28: error: 'uint32_t' has not been declared
68 \|     std::string utf8Encode(uint32_t codepoint);
\|                            ^~~~~~~~
../src/FontParser.h:68:28: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.h:83:5: error: 'uint32_t' does not name a type
83 \|     uint32_t parseUnicode();
\|     ^~~~~~~~
../src/FontParser.h:83:5: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.h: In member function 'bool Tokenizer::isWhitespace(char) const':
../src/FontParser.h:70:14: error: 'charData' was not declared in this scope; did you mean 'CharData'?
70 \|       return charData[static_cast<uint8_t>(c)] & CharData::Whitespace;
\|              ^~~~~~~~
\|              CharData
../src/FontParser.h:70:35: error: 'uint8_t' does not name a type
70 \|       return charData[static_cast<uint8_t>(c)] & CharData::Whitespace;
\|                                   ^~~~~~~
../src/FontParser.h:70:35: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.h:70:60: error: 'Whitespace' is not a member of 'CharData'
70 \|       return charData[static_cast<uint8_t>(c)] & CharData::Whitespace;
\|                                                            ^~~~~~~~~~
../src/FontParser.h: In member function 'bool Tokenizer::isNewline(char) const':
../src/FontParser.h:73:14: error: 'charData' was not declared in this scope; did you mean 'CharData'?
73 \|       return charData[static_cast<uint8_t>(c)] & CharData::Newline;
\|              ^~~~~~~~
\|              CharData
../src/FontParser.h:73:35: error: 'uint8_t' does not name a type
73 \|       return charData[static_cast<uint8_t>(c)] & CharData::Newline;
\|                                   ^~~~~~~
../src/FontParser.h:73:35: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.h:73:60: error: 'Newline' is not a member of 'CharData'
73 \|       return charData[static_cast<uint8_t>(c)] & CharData::Newline;
\|                                                            ^~~~~~~
../src/FontParser.h: At global scope:
../src/FontParser.h:93:50: error: 'uint16_t' was not declared in this scope
93 \|     static const std::unordered_map<std::string, uint16_t> weightMap;
\|                                                  ^~~~~~~~
../src/FontParser.h:93:50: note: 'uint16_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.h:93:58: error: template argument 2 is invalid
93 \|     static const std::unordered_map<std::string, uint16_t> weightMap;
\|                                                          ^
../src/FontParser.h:93:58: error: template argument 5 is invalid
../src/FontParser.cc:36:1: error: 'std::string Tokenizer::utf8Encode' is not a static data member of 'class Tokenizer'
36 \| Tokenizer::utf8Encode(uint32_t codepoint) {
\| ^~~~~~~~~
../src/FontParser.cc:36:23: error: 'uint32_t' was not declared in this scope
36 \| Tokenizer::utf8Encode(uint32_t codepoint) {
\|                       ^~~~~~~~
../src/FontParser.cc:10:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
9 \| #include "FontParser.h"
+++ \|+#include <cstdint>
10 \| #include "CharData.h"
../src/FontParser.cc:36:43: error: expected ',' or ';' before '{' token
36 \| Tokenizer::utf8Encode(uint32_t codepoint) {
\|                                           ^
../src/FontParser.cc: In member function 'Token Tokenizer::parseNumber()':
../src/FontParser.cc:87:5: error: 'uint8_t' was not declared in this scope
87 \|     uint8_t flags = charData[static_cast<uint8_t>(c)];
\|     ^~~~~~~
../src/FontParser.cc:87:5: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.cc:91:13: error: 'flags' was not declared in this scope
91 \|         if (flags & CharData::Sign) {
\|             ^~~~~
../src/FontParser.cc:91:31: error: 'Sign' is not a member of 'CharData'
91 \|         if (flags & CharData::Sign) {
\|                               ^~~~
../src/FontParser.cc:94:38: error: 'Digit' is not a member of 'CharData'
94 \|         } else if (flags & CharData::Digit) {
\|                                      ^~~~~
../src/FontParser.cc:107:13: error: 'flags' was not declared in this scope
107 \|         if (flags & CharData::Digit) {
\|             ^~~~~
../src/FontParser.cc:107:31: error: 'Digit' is not a member of 'CharData'
107 \|         if (flags & CharData::Digit) {
\|                               ^~~~~
../src/FontParser.cc:120:13: error: 'flags' was not declared in this scope
120 \|         if (flags & CharData::Digit) {
\|             ^~~~~
../src/FontParser.cc:120:31: error: 'Digit' is not a member of 'CharData'
120 \|         if (flags & CharData::Digit) {
\|                               ^~~~~
../src/FontParser.cc:136:13: error: 'flags' was not declared in this scope
136 \|         if (flags & CharData::Digit) {
\|             ^~~~~
../src/FontParser.cc:136:31: error: 'Digit' is not a member of 'CharData'
136 \|         if (flags & CharData::Digit) {
\|                               ^~~~~
../src/FontParser.cc:146:13: error: 'flags' was not declared in this scope
146 \|         if (flags & CharData::Sign) {
\|             ^~~~~
../src/FontParser.cc:146:31: error: 'Sign' is not a member of 'CharData'
146 \|         if (flags & CharData::Sign) {
\|                               ^~~~
../src/FontParser.cc:149:38: error: 'Digit' is not a member of 'CharData'
149 \|         } else if (flags & CharData::Digit) {
\|                                      ^~~~~
../src/FontParser.cc:161:13: error: 'flags' was not declared in this scope
161 \|         if (flags & CharData::Digit) {
\|             ^~~~~
../src/FontParser.cc:161:31: error: 'Digit' is not a member of 'CharData'
161 \|         if (flags & CharData::Digit) {
\|                               ^~~~~
../src/FontParser.cc:173:13: error: 'flags' was not declared in this scope
173 \|         if (flags & CharData::Digit) {
\|             ^~~~~
../src/FontParser.cc:173:31: error: 'Digit' is not a member of 'CharData'
173 \|         if (flags & CharData::Digit) {
\|                               ^~~~~
../src/FontParser.cc: In member function 'Token Tokenizer::parseIdentifier()':
../src/FontParser.cc:200:26: error: 'Nmstart' is not a member of 'CharData'
200 \|   auto flags = CharData::Nmstart;
\|                          ^~~~~~~
../src/FontParser.cc:212:25: error: 'Nmchar' is not a member of 'CharData'
212 \|       flags = CharData::Nmchar;
\|                         ^~~~~~
../src/FontParser.cc:213:16: error: 'charData' was not declared in this scope; did you mean 'CharData'?
213 \|     } else if (charData[static_cast<uint8_t>(c)] & flags) {
\|                ^~~~~~~~
\|                CharData
../src/FontParser.cc:213:37: error: 'uint8_t' does not name a type
213 \|     } else if (charData[static_cast<uint8_t>(c)] & flags) {
\|                                     ^~~~~~~
../src/FontParser.cc:213:37: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.cc:215:25: error: 'Nmchar' is not a member of 'CharData'
215 \|       flags = CharData::Nmchar;
\|                         ^~~~~~
../src/FontParser.cc: At global scope:
../src/FontParser.cc:224:1: error: 'uint32_t' does not name a type
224 \| uint32_t
\| ^~~~~~~~
../src/FontParser.cc:224:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.cc: In member function 'bool Tokenizer::parseEscape(std::string&)':
../src/FontParser.cc:263:16: error: 'charData' was not declared in this scope; did you mean 'CharData'?
263 \|   auto flags = charData[static_cast<uint8_t>(c)];
\|                ^~~~~~~~
\|                CharData
../src/FontParser.cc:263:37: error: 'uint8_t' does not name a type
263 \|   auto flags = charData[static_cast<uint8_t>(c)];
\|                                     ^~~~~~~
../src/FontParser.cc:263:37: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.cc:265:25: error: 'Hex' is not a member of 'CharData'
265 \|   if (flags & CharData::Hex) {
\|                         ^~~
../src/FontParser.cc:266:23: error: 'parseUnicode' was not declared in this scope
266 \|     str += utf8Encode(parseUnicode());
\|                       ^~~~~~~~~~~~
../src/FontParser.cc:268:34: error: 'Newline' is not a member of 'CharData'
268 \|   } else if (!(flags & CharData::Newline) && !(flags & CharData::Hex)) {
\|                                  ^~~~~~~
../src/FontParser.cc:268:66: error: 'Hex' is not a member of 'CharData'
268 \|   } else if (!(flags & CharData::Newline) && !(flags & CharData::Hex)) {
\|                                                                  ^~~
../src/FontParser.cc: In member function 'Token Tokenizer::nextToken()':
../src/FontParser.cc:318:16: error: 'charData' was not declared in this scope; did you mean 'CharData'?
318 \|   auto flags = charData[static_cast<uint8_t>(c)];
\|                ^~~~~~~~
\|                CharData
../src/FontParser.cc:318:37: error: 'uint8_t' does not name a type
318 \|   auto flags = charData[static_cast<uint8_t>(c)];
\|                                     ^~~~~~~
../src/FontParser.cc:318:37: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.cc:328:25: error: 'NumStart' is not a member of 'CharData'
328 \|   if (flags & CharData::NumStart) {
\|                         ^~~~~~~~
../src/FontParser.cc:333:25: error: 'Nmstart' is not a member of 'CharData'
333 \|   if (flags & CharData::Nmstart) {
\|                         ^~~~~~~
../src/FontParser.cc: At global scope:
../src/FontParser.cc:361:39: error: 'uint16_t' was not declared in this scope
361 \| const std::unordered_map<std::string, uint16_t> FontParser::weightMap = {
\|                                       ^~~~~~~~
../src/FontParser.cc:361:39: note: 'uint16_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.cc:361:47: error: template argument 2 is invalid
361 \| const std::unordered_map<std::string, uint16_t> FontParser::weightMap = {
\|                                               ^
../src/FontParser.cc:361:47: error: template argument 5 is invalid
../src/FontParser.cc:361:49: error: scalar object 'FontParser::weightMap' requires one element in initializer
361 \| const std::unordered_map<std::string, uint16_t> FontParser::weightMap = {
\|                                                 ^~~~~~~~~~
../src/FontParser.cc: In member function 'bool FontParser::parseFontWeight(FontProperties&)':
../src/FontParser.cc:446:11: error: 'struct FontProperties' has no member named 'fontWeight'
446 \|     props.fontWeight = static_cast<uint16_t>(weight);
\|           ^~~~~~~~~~
../src/FontParser.cc:446:36: error: 'uint16_t' does not name a type
446 \|     props.fontWeight = static_cast<uint16_t>(weight);
\|                                    ^~~~~~~~
../src/FontParser.cc:446:36: note: 'uint16_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.cc:453:13: error: 'struct FontProperties' has no member named 'fontWeight'
453 \|       props.fontWeight = it->second;
\|             ^~~~~~~~~~
../src/FontParser.cc: In member function 'FontProperties FontParser::parseFont()':
../src/FontParser.cc:572:3: error: 'uint8_t' was not declared in this scope
572 \|   uint8_t state = 0b111;
\|   ^~~~~~~
../src/FontParser.cc:572:3: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
../src/FontParser.cc:577:10: error: 'state' was not declared in this scope
577 \|     if ((state & 0b001) && parseFontStyle(props)) {
\|          ^~~~~
../src/FontParser.cc:582:10: error: 'state' was not declared in this scope
582 \|     if ((state & 0b010) && parseFontVariant(props)) {
\|          ^~~~~
../src/FontParser.cc:587:10: error: 'state' was not declared in this scope
587 \|     if ((state & 0b100) && parseFontWeight(props)) {
\|          ^~~~~
make: *** [canvas.target.mk:158: Release/obj.target/canvas/src/FontParser.o] Error 1
make: Leaving directory '/server/node_modules/canvas/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:219:23)
gyp ERR! System Linux 4.14.355-280.708.amzn2.x86_64
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /server/node_modules/canvas
gyp ERR! node -v v22.21.1
gyp ERR! node-gyp -v v11.2.0
gyp ERR! not ok

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions