Registry / web-framework / image-loader-next

image-loader-next

JSON →
library0.1.2jsnpmunverified

A package that allows loading image files (PNG, SVG, JPG, JPEG, GIF, WebP, AVIF, ICO, BMP) in Node.js, Rollup, Vite, or Vitest the same way as Next.js. Current stable version is 0.1.2. It provides a Rollup plugin and a Node.js loader. The generated modules expose src, width, height, and a default export. Compatible with Node.js 22+. Key differentiator: it mimics Next.js image handling in non-Next.js environments, enabling consistent image imports across tools.

npm install image-loader-next
INSTALL
IMPORT
SIG · IMAGE-LOADER-NEXT
I
image-loader-next
web-frameworkjavascriptv0.1.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

nextImages
✓ import { nextImages } from 'image-loader-next/rollup'
✗ import nextImages from 'image-loader-next/rollup'
Named export from the rollup subpath.
register (Node.js loader)
✓ register('image-loader-next/node', import.meta.url)
Use with node:module register function.
Node.js loader via --loader flag
✓ node --loader image-loader-next

Shows Vite plugin setup and Node.js loader registration then image import usage.

// Vite config import { nextImages } from 'image-loader-next/rollup' import { defineConfig } from 'vite' export default defineConfig({ plugins: [nextImages()] }) // Usage in component import logo from './logo.png' console.log(logo.src, logo.width, logo.height) // Node.js loader import { register } from 'node:module' register('image-loader-next/node', import.meta.url) import logo from './logo.png' console.log(logo.src, logo.width, logo.height)
Debug
Known issues
breakingNode.js 22+ required; older versions not supported.
fix
Upgrade Node.js to version 22 or higher.
affects: <22.0.0
gotchaDefault export is an object with src, width, height — not a string.
fix
Access .src for the URL string: 
import img from './img.png'
console.log(img.src, img.width, img.height)
affects: *
gotchaPlugin uses Rollup include/exclude filters; Vite config integration requires correct import path.
fix
Ensure import { nextImages } from 'image-loader-next/rollup' and not from 'image-loader-next'.
affects: *
gotchaNode.js loader must be registered before importing images; order matters with other loaders.
fix
Register the loader early in your entry file (e.g., at the top of the main module).
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'image-loader-next/node'
Package not installed or wrong import path.
fix
Install the package: npm install image-loader-next. Use correct subpath: 'image-loader-next/node'.
TypeError: nextImages is not a function
Incorrect import (e.g., default instead of named import).
fix
Use: import { nextImages } from 'image-loader-next/rollup'
Error: The --experimental-loader flag is required for Node.js loaders.
Using Node.js version <22 or not using --loader correctly.
fix
Upgrade to Node.js 22+ and use `node --loader image-loader-next` or call `register()` programmatically.
Upgrade
Version history
0.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
image-loader-next — npm install image-loader-next · libregistry