Comments (5)
@WGlint In your case, this is definitely a NextJS (or build) issue. You can find plenty of information about that already. Even just adding an explicit "use server"
might fix it, but I don't have a convenient NextJS project to test this on right now.
While I suspect the serverless issue to be similar, I can't really tell without seeing the problem. Searching for "serverless" is much more annoying than searching for "nextjs", since serverless is both a module and a concept and you get a lot of results about the concept.
In general, server-side modules should be able to access fs
just fine. Some more recent frameworks (like NextJS for example) try to instrument that away from you (in the case of NextJS, it is well-meaning, in that they want all your code to transparently be able to be compiled for either the browser or the server without you understanding where it is going).
Anyway, recent versions of libheif-js
now use web assembly for a significant performance improvement. The actual runtime code shouldn't use fs
, but I am sure that the emscripten boilerplate ends up requiring it for some reason anyway.
Best advice for now is:
- if you want to run it in the browser, use
require('heic-convert/browser')
as mentioned in the docs - if you want to use it on the server, make sure whatever framework you are using it in knows you are using it on the server and that you have access to expected standard server capabilities (like
fs
) when doing so
from heic-convert.
More information is needed for this issue.
from heic-convert.
Got same issue. (stack: nodeJS, serverless framework)
from heic-convert.
@BenMoreton do you happen to have a minimal repro project that shows this issue?
from heic-convert.
@BenMoreton do you happen to have a minimal repro project that shows this issue?
I got the same error message. I'm using NextJS 14.1 and i use heic-convert
in a route.ts file. This is my following code for this api file ( this turn in Nodejs by default ):
import { NextResponse } from "next/server";
import heicConvert from "heic-convert";
export async function POST(request : Request){
const reader = await request.arrayBuffer()
console.log(reader)
console.log(Buffer.from(reader))
const heic = await heicConvert({
buffer : Buffer.from(reader),
format : "PNG",
quality : 1
})
const response = new NextResponse(heic, {
headers : {
"Content-Type" : "image/png"
}
})
return response
}
I want to build my projet for make a try in production, so i use npm run build
and npm run start
and i got this following error message :
info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
✓ Linting and checking validity of types
Collecting page data .Error: Cannot find module 'fs'
at I (/Users/wglint/Desktop/ServerAI/serverai/.next/server/app/api/check/route.js:1:77)
at /Users/wglint/Desktop/ServerAI/serverai/.next/server/app/api/check/route.js:1:24025
at c (/Users/wglint/Desktop/ServerAI/serverai/.next/server/app/api/check/route.js:24:1098358)
at 2388 (/Users/wglint/Desktop/ServerAI/serverai/.next/server/app/api/check/route.js:24:1098483)
at t (/Users/wglint/Desktop/ServerAI/serverai/.next/server/webpack-runtime.js:1:127)
at 9704 (/Users/wglint/Desktop/ServerAI/serverai/.next/server/app/api/check/route.js:1:2750)
at t (/Users/wglint/Desktop/ServerAI/serverai/.next/server/webpack-runtime.js:1:127)
at 8816 (/Users/wglint/Desktop/ServerAI/serverai/.next/server/app/api/check/route.js:1:2008)
at t (/Users/wglint/Desktop/ServerAI/serverai/.next/server/webpack-runtime.js:1:127)
at 4157 (/Users/wglint/Desktop/ServerAI/serverai/.next/server/app/api/check/route.js:1:858) {
code: 'MODULE_NOT_FOUND'
}
> Build error occurred
Error: Failed to collect page data for /api/check
at /Users/wglint/Desktop/ServerAI/serverai/node_modules/next/dist/build/utils.js:1258:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'Error'
}
Collecting page data .%
I install the latest version of heic-convert ( "heic-convert": "^2.1.0"
), i don't get how to solve this error x).
EDIT : With the version 1.2.4, i don't have problem
from heic-convert.
Related Issues (20)
- Add typescript support HOT 2
- Question: Does this retain the image metadata? HOT 2
- Browser vs Server Side Support HOT 1
- how can i use this code in php HOT 1
- 5MB image take time almost 20 sec in AWS Lambda function HOT 3
- no license HOT 1
- image not convert into JPEG HOT 1
- HEIF cannot convert to Jpg HOT 1
- Vulnerability in "jpeg-js" dependency found HOT 1
- TypeError: input buffer is not a HEIC image HOT 4
- Wrong image rotation/orientation applied to output HOT 8
- Example of usage with a base64 string. HOT 2
- Thank you so much HOT 1
- Access to auxiliary images
- TypeError: input buffer is not a HEIC image when passing image from base64 buffer HOT 2
- using in react native? HOT 1
- Uncaught TypeError: util.inherits is not a function HOT 3
- move CI to GitHub Actions
- Spread syntax requires ...iterable[Symbol.iterator] to be a function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from heic-convert.