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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
json-loader (loader reference)
✓ In webpack config: { test: /\.json$/, loader: 'json-loader' }
✗ require('json-loader') directly in code (not a JS module)
In webpack v1, this loader is needed. Since webpack v2, JSON files work without this loader.
Inline usage
✓ const json = require('json-loader!./file.json');
✗ const json = require('json-loader')(require('./file.json'));
Inline usage is for webpack v1; in v2+ just require the JSON file directly.
Default import (ES modules)
✓ import 'json-loader' (no direct use; configured in webpack)
✗ import jsonLoader from 'json-loader'
json-loader is not a JavaScript module to import; it's a webpack loader referenced in config.
Shows how to configure json-loader in webpack v1 to import JSON files.
// webpack.config.js (webpack v1)
module.exports = {
entry: './app.js',
output: { filename: 'bundle.js' },
module: {
loaders: [
{ test: /\.json$/, loader: 'json-loader' }
]
}
};
// app.js
var data = require('./data.json');
console.log(data);
Errors
Common errors & fixes
Module parse failed: Unexpected token (1:1)
You may need an appropriate loader to handle this file type.
When webpack v1 is used without json-loader, it cannot parse JSON files.
fixAdd json-loader to webpack config with test: /\.json$/.
DeprecationWarning: json-loader is deprecated. Since webpack v2, JSON files are supported by default.
Using json-loader with webpack v2 or later triggers a deprecation warning.
fixRemove json-loader from config and let webpack handle JSON natively.
Cannot find module 'json-loader'
json-loader is not installed or not in node_modules.
fixRun: npm install --save-dev json-loader
Audit
Dependencies
webpackrequiredwebpack peer dependency; loader requires webpack to function