Registry / devops / awesome-node-loader

awesome-node-loader

JSON →
library1.1.1jsnpmunverified

awesome-node-loader is a webpack loader designed to correctly bundle and handle Node.js native addon files, typically with a `.node` extension, within a webpack build process. It is currently at version 1.1.1 and explicitly supports webpack v4. The package appears to be in maintenance mode, with no recent releases indicating active development for newer webpack versions (v5+). Its primary purpose is to ensure that native modules, which are often pre-compiled C++ addons, are properly copied to the output directory and their paths are correctly resolved at runtime, preventing common 'module not found' errors. Key differentiators include its focus on native modules, which is crucial for applications built with frameworks like Electron or when bundling for environments that rely on specific native dependencies, allowing developers to embed these dependencies rather than requiring them to be present in the target environment's Node Modules.

npm install awesome-node-loader
INSTALL
IMPORT
SIG · AWESOME-NODE-LOADE
A
awesome-node-loader
devopsjavascriptv1.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

awesome-node-loader
module.exports = { // ... module: { rules: [ { test: /\.node$/, loader: 'awesome-node-loader' } ] } };
This loader is configured as a string within webpack's `module.rules` array. There are no direct JavaScript imports or requires for this package in application code.
options
module.exports = { // ... module: { rules: [ { test: /\.node$/, loader: 'awesome-node-loader', options: { name: '[name].[ext]', rewritePath: 'dist/native_modules' } } ] } };
Loader options are passed as an object within the `rules` configuration.

This webpack configuration demonstrates how to integrate `awesome-node-loader` to correctly process native `.node` files, specifying output paths and handling common external dependencies for Node.js environments.

const path = require('path'); module.exports = { mode: 'production', target: 'node', entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js', }, module: { rules: [ { test: /\.node$/, loader: 'awesome-node-loader', options: { name: '[name].[ext]', // Keeps the original file name // Specify an absolute path where native modules should be outputted. // For pkg or Electron, this might be a sub-directory. rewritePath: path.resolve(__dirname, 'dist/native_modules'), // When rewritePath is relative, use __dirname for resolution useDirname: true } } ] }, // Important for Node applications to correctly resolve built-in modules externals: [ { // Prevent webpack from bundling Node.js built-in modules // This is crucial for native addons that may depend on them. 'fs': 'commonjs fs', 'path': 'commonjs path', 'buffer': 'commonjs buffer', 'crypto': 'commonjs crypto' } ] };
Debug
Known issues
gotchaExplicit support for `webpack v4` suggests potential incompatibility with `webpack v5` or newer versions, leading to build failures or incorrect module resolution. Users on newer webpack versions should verify compatibility or consider alternative loaders.
fix
Check the project's GitHub for compatibility updates or use a different loader (e.g., `node-loader` with appropriate configuration for newer webpack versions). Consider pinning webpack to v4 if this loader is critical.
affects: >=1.0.0
gotchaMisconfiguring `rewritePath` or `useDirname` options can lead to runtime errors like 'Module not found' or 'Module did not self-register' for native `.node` files, especially when bundling for different target environments (e.g., Electron, `pkg`). The `rewritePath` option should typically be `undefined` if embedding files directly into a self-contained package.
fix
Carefully review `rewritePath` and `useDirname` options. Ensure `rewritePath` is an absolute path to where the native module should reside at runtime, or `undefined` if webpack should handle its default embedding. Test thoroughly in the target environment.
affects: >=1.0.0
gotchaNative `.node` modules are platform and architecture-specific. Using `awesome-node-loader` correctly bundles the specified `.node` files but does not automatically cross-compile or provide multiple binaries for different platforms (e.g., Windows, macOS, Linux, ARM, x64).
fix
Ensure that the `.node` files being bundled are pre-compiled for the specific target platform(s) and architecture(s) where the bundled application will run. For multi-platform support, you may need separate builds or dynamic loading of platform-specific binaries.
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'awesome-node-loader' in '...' (webpack compile error)
Webpack cannot find the loader package because it's not installed or incorrectly referenced.
fix
Run `npm install awesome-node-loader --save-dev` or `yarn add --dev awesome-node-loader` to install the loader in your project's dev dependencies.
Error: The specified module could not be found. (Windows) or Error: Module did not self-register. (Linux/macOS) at process.dlopen (node:internal/modules/cjs/loader:XXXX)
A native `.node` module is not found or incorrectly linked at runtime, often due to an incorrect output path or resolution.
fix
Verify the `rewritePath` and `useDirname` options in your `webpack.config.js`. Ensure the native module is copied to the correct runtime location and that Node.js can resolve its path. Use `path.resolve(__dirname, '...')` for absolute paths.
ERROR in awesome-node-loader.js from awesome-node-loader / Webpack compilation failed: Cannot read property 'get' of undefined
The loader might be incompatible with the current Webpack version (e.g., Webpack 5+), as it specifically mentions Webpack 4 support.
fix
Check if your Webpack version is 4.x. If you're on Webpack 5 or newer, consider using an alternative loader that explicitly supports your Webpack version, or investigate if there are community-provided patches/forks for `awesome-node-loader`.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
awesome-node-loader — npm install awesome-node-loader · libregistry