
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
node-loader-nextjs
Advanced tools
A Node.js add-ons loader.
Allows to connect native node modules with .node extension.
⚠
node-loaderonly works on thenode/async-node/electron-main/electron-renderer/electron-preloadtargets.
To begin, you'll need to install node-loader:
$ npm install node-loader --save-dev
Setup the target option to node/async-node/electron-main/electron-renderer/electron-preload value and do not mock the __dirname global variable.
webpack.config.js
module.exports = {
target: "node",
node: {
__dirname: false,
},
module: {
rules: [
{
test: /\.node$/,
loader: "node-loader",
},
],
},
};
index.js
import node from "node-loader!./file.node";
And run webpack via your preferred method.
index.js
import node from "file.node";
Then add the loader to your webpack config. For example:
webpack.config.js
module.exports = {
target: "node",
node: {
__dirname: false,
},
module: {
rules: [
{
test: /\.node$/,
loader: "node-loader",
},
],
},
};
And run webpack via your preferred method.
| Name | Type | Default | Description |
|---|---|---|---|
flags | {Number} | undefined | Enables/Disables url/image-set functions handling |
name | {String|Function} | '[contenthash].[ext]' | Specifies a custom filename template for the target file(s). |
flagsType: Number
Default: undefined
The flags argument is an integer that allows to specify dlopen behavior.
See the process.dlopen documentation for details.
index.js
import node from "file.node";
webpack.config.js
const os = require("os");
module.exports = {
target: "node",
node: {
__dirname: false,
},
module: {
rules: [
{
test: /\.node$/,
loader: "node-loader",
options: {
flags: os.constants.dlopen.RTLD_NOW,
},
},
],
},
};
nameType: String|Function
Default: '[contenthash].[ext]'
Specifies a custom filename template for the target file(s).
Stringwebpack.config.js
module.exports = {
target: "node",
node: {
__dirname: false,
},
module: {
rules: [
{
test: /\.node$/,
loader: "node-loader",
options: {
name: "[path][name].[ext]",
},
},
],
},
};
Functionwebpack.config.js
module.exports = {
target: "node",
node: {
__dirname: false,
},
module: {
rules: [
{
test: /\.node$/,
loader: "node-loader",
options: {
name(resourcePath, resourceQuery) {
// `resourcePath` - `/absolute/path/to/file.js`
// `resourceQuery` - `?foo=bar`
if (process.env.NODE_ENV === "development") {
return "[path][name].[ext]";
}
return "[contenthash].[ext]";
},
},
},
],
},
};
Please take a moment to read our contributing guidelines if you haven't yet done so.
FAQs
A Node loader module for enhanced-require
The npm package node-loader-nextjs receives a total of 8 weekly downloads. As such, node-loader-nextjs popularity was classified as not popular.
We found that node-loader-nextjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.