Nodejs canvas in actions.
Are we not allowed to use packages like: https://www.npmjs.com/package/canvas ?
It has native bindings to what looks like python.
I tried precompiling it in docker container and just chucking the canvas package inline in a _vendor folder in ./convex... that also didn't work.
I tried adding it to externalPackages:
My action just looks like this:
{
"node": {
"externalPackages": [
"canvas"
]
}
}
{
"node": {
"externalPackages": [
"canvas"
]
}
}
'use node';
import { action } from '@convex/_generated/server';
import { createCanvas } from 'canvas';
export const checkServerArchitecture = action({
args: {},
handler: async (ctx, args) => {
console.log('Platform:', process.platform);
console.log('Architecture:', process.arch);
console.log('Node.js Version:', process.version);
const canvas = createCanvas(200, 200);
return 'ok';
},
});
'use node';
import { action } from '@convex/_generated/server';
import { createCanvas } from 'canvas';
export const checkServerArchitecture = action({
args: {},
handler: async (ctx, args) => {
console.log('Platform:', process.platform);
console.log('Architecture:', process.arch);
console.log('Node.js Version:', process.version);
const canvas = createCanvas(200, 200);
return 'ok';
},
});
npm
canvas
Canvas graphics API backed by Cairo. Latest version: 3.1.0, last published: 4 months ago. Start using canvas in your project by running
npm i canvas
. There are 2899 other projects in the npm registry using canvas.2 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
The terminal logs:
And I get an error in the console:
✖ Error: Unable to push deployment config to https://kindly-axolotl-103.convex.cloud
✖ Error fetching POST https://kindly-axolotl-103.convex.cloud/api/push_config 400 Bad Request: InvalidExternalModules: Hit an error while pushing:
Loading the pushed modules encountered the following error:
Command failed: npm install
npm error code 1
npm error path /tmp/build_deps/node_modules/canvas
npm error command failed
npm error command sh -c prebuild-install -r napi || node-gyp rebuild
npm error prebuild-install warn install No prebuilt binaries found (target=7 runtime=napi arch=arm64 libc= platform=linux)
npm error gyp info it worked if it ends with ok
npm error gyp info using node-gyp@10.1.0
npm error gyp info using node@18.20.6 | linux | arm64
npm error gyp ERR! find Python
npm error gyp ERR! find Python Python is not set from command line or npm configuration
npm error gyp ERR! find Python Python is not set from environment variable PYTHON
npm error gyp ERR! find Python checking if "python3" can be used
npm error gyp ERR! find Python - executable path is ""
npm error gyp ERR! find Python - "" could not be run
npm error gyp ERR! find Python checking if "python" can be used
npm error gyp ERR! find Python - executable path is ""
npm error gyp ERR! find Python - "" could not be run
npm error gyp ERR! find Python
npm error gyp ERR! find Python **********************************************************
npm error gyp ERR! find Python You need to install the latest version of Python.
npm error gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm error gyp ERR! find Python you can try one of the following options:
npm error gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
npm error gyp ERR! find Python (accepted by both node-gyp and npm)
npm error gyp ERR! find Python - Set the environment variable PYTHON
npm error gyp ERR! find Python - Set the npm configuration variable python:
npm error gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
npm error gyp ERR! find Python For more information consult the documentation at:
npm error gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm error gyp ERR! find Python **********************************************************
npm error gyp ERR! find Python
npm error gyp ERR! configure error
npm error gyp ERR! stack Error: Could not find any Python installation to use
npm error gyp ERR! stack at PythonFinder.fail (/var/lang/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:306:11)
npm error gyp ERR! stack at PythonFinder.findPython (/var/lang/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:164:17)
npm error gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm error gyp ERR! stack at async configure (/var/lang/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:27:18)
npm error gyp ERR! stack at async run (/var/lang/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:81:18)
npm error gyp ERR! System Linux 5.10.236-248.928.amzn2.aarch64
npm error gyp ERR! command "/var/lang/bin/node" "/var/lang/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm error gyp ERR! cwd /tmp/build_deps/node_modules/canvas
npm error gyp ERR! node -v v18.20.6
npm error gyp ERR! node-gyp -v v10.1.0
npm error gyp ERR! not ok
npm notice
npm notice New major version of npm available! 10.8.2 -> 11.3.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.3.0
npm notice To update run: npm install -g npm@11.3.0
npm notice
npm error A complete log of this run can be found in: /tmp/build_deps/.npm/_logs/2025-05-07T21_39_01_992Z-debug-0.log
✖ Error: Unable to push deployment config to https://kindly-axolotl-103.convex.cloud
✖ Error fetching POST https://kindly-axolotl-103.convex.cloud/api/push_config 400 Bad Request: InvalidExternalModules: Hit an error while pushing:
Loading the pushed modules encountered the following error:
Command failed: npm install
npm error code 1
npm error path /tmp/build_deps/node_modules/canvas
npm error command failed
npm error command sh -c prebuild-install -r napi || node-gyp rebuild
npm error prebuild-install warn install No prebuilt binaries found (target=7 runtime=napi arch=arm64 libc= platform=linux)
npm error gyp info it worked if it ends with ok
npm error gyp info using node-gyp@10.1.0
npm error gyp info using node@18.20.6 | linux | arm64
npm error gyp ERR! find Python
npm error gyp ERR! find Python Python is not set from command line or npm configuration
npm error gyp ERR! find Python Python is not set from environment variable PYTHON
npm error gyp ERR! find Python checking if "python3" can be used
npm error gyp ERR! find Python - executable path is ""
npm error gyp ERR! find Python - "" could not be run
npm error gyp ERR! find Python checking if "python" can be used
npm error gyp ERR! find Python - executable path is ""
npm error gyp ERR! find Python - "" could not be run
npm error gyp ERR! find Python
npm error gyp ERR! find Python **********************************************************
npm error gyp ERR! find Python You need to install the latest version of Python.
npm error gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm error gyp ERR! find Python you can try one of the following options:
npm error gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
npm error gyp ERR! find Python (accepted by both node-gyp and npm)
npm error gyp ERR! find Python - Set the environment variable PYTHON
npm error gyp ERR! find Python - Set the npm configuration variable python:
npm error gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
npm error gyp ERR! find Python For more information consult the documentation at:
npm error gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm error gyp ERR! find Python **********************************************************
npm error gyp ERR! find Python
npm error gyp ERR! configure error
npm error gyp ERR! stack Error: Could not find any Python installation to use
npm error gyp ERR! stack at PythonFinder.fail (/var/lang/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:306:11)
npm error gyp ERR! stack at PythonFinder.findPython (/var/lang/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:164:17)
npm error gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm error gyp ERR! stack at async configure (/var/lang/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:27:18)
npm error gyp ERR! stack at async run (/var/lang/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:81:18)
npm error gyp ERR! System Linux 5.10.236-248.928.amzn2.aarch64
npm error gyp ERR! command "/var/lang/bin/node" "/var/lang/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm error gyp ERR! cwd /tmp/build_deps/node_modules/canvas
npm error gyp ERR! node -v v18.20.6
npm error gyp ERR! node-gyp -v v10.1.0
npm error gyp ERR! not ok
npm notice
npm notice New major version of npm available! 10.8.2 -> 11.3.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.3.0
npm notice To update run: npm install -g npm@11.3.0
npm notice
npm error A complete log of this run can be found in: /tmp/build_deps/.npm/_logs/2025-05-07T21_39_01_992Z-debug-0.log