Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
nextjs-node-loader
Advanced tools
Allows you to include native Node.js `.node` modules in your Next.js project
Status: Deprecated
There's no need for it anymore. I've added an example in next 14 to demo including different native modules. Solution in NextJS 14 is to add a:
experimental: {
serverComponentsExternalPackages: ['yournativemodule'],
}
For a dependency built with neon bindings, you might also need to configure externals
:
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ['mynativemodule'],
},
/** @type {import('webpack').Configuration} */
webpack: (config, context) => {
if (context.isServer) {
config.externals = [
...config.externals,
{'mynativemodule': 'commonjs mynativemodule'},
]
}
return config;
},
};
A huge thank you to everyone who contributed to this project! ❤️
For historical purposes, the original README is preserved below.
This is a custom loader for Webpack that allows you to include native Node.js .node
modules in your Next.js project.
It simplifies the process of loading native modules by providing a standardized interface that works seamlessly with
Next.js.
This is a modified version of Node loader.
More context on the why and example use of the loader in my blog post.
To begin, you'll need to install a nextjs-node-loader
:
npm install nextjs-node-loader --save-dev
next.config.js
module.exports = {
webpack: (config, { dev, isServer, webpack, nextRuntime }) => {
config.module.rules.push({
test: /\.node$/,
use: [
{
loader: "nextjs-node-loader",
options: {
flags: os.constants.dlopen.RTLD_NOW,
outputPath: config.output.path
}
},
],
});
return config;
},
};
And use in e.g. your api route;
import module from "node-module";
export default function handler(req, res) {
// ...
}
Name | Type | Default | Description |
---|---|---|---|
flags | {Number} | undefined | Enables/Disables url /image-set functions handling |
outputPath | {String} | webpack's outputPath | The root path of shared node libraries |
includeWebpackPublicPath | {String} | false | If webpack_public_path should be included in a path for loading node module. For nextjs >13.2.5 should be false. |
FAQs
Allows you to include native Node.js `.node` modules in your Next.js project
The npm package nextjs-node-loader receives a total of 7,096 weekly downloads. As such, nextjs-node-loader popularity was classified as popular.
We found that nextjs-node-loader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.