I'm trying to make a simple api with js. But i keep getting this stupid error. NOTE: This is my first time programming in js.
Code:
const express = require('express')
const app = express()
const { Canvas } = require('canvas-constructor')
const canvas = require('canvas')
app.get('/:feed', async (req, res) => {
const img = await canvas.loadImage('https://i.pinimg.com/originals/30/82/b0/3082b0354572c4d37af6994b4e8baa43.png')
let image = new Canvas(670, 435)
.printImage(img, 0, 0, 670, 435)
.setTextFont('28px Impact')
.printText(req.params.feed, 40, 150)
.toBuffer();
res.set({'Content-Type': 'image/png'})
res.send(image)//sending the image!
})
app.listen(8080)
Error:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /home/runner/ScarceExcellentVariables/node_modules/canvas-constructor/package.json
at new NodeError (node:internal/errors:371:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:440:9)
at packageExportsResolve (node:internal/modules/esm/resolve:692:3)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
If anyone could help me i'd appreciate it
Via Active questions tagged javascript - Stack Overflow https://ift.tt/yKeT96C
Comments
Post a Comment