Registry / devops / robotstxt-webpack-plugin

robotstxt-webpack-plugin

JSON →
library8.0.0jsnpmunverified

A webpack plugin to generate a robots.txt file for your project. Version 8.0.0 is current, released August 2022. It requires webpack 5+ and Node.js >=14.15.0. Built on top of generate-robotstxt, it supports all options from that package. Simplified setup compared to manual creation, integrates with webpack's asset pipeline. Last update was 2022; no recent activity, but still functional for webpack 5 projects.

npm install robotstxt-webpack-plugin
INSTALL
IMPORT
SIG · ROBOTSTXT-WEBPACK-
R
robotstxt-webpack-plugin
devopsjavascriptv8.0.0
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–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

RobotstxtPlugin
✓ const RobotstxtPlugin = require('robotstxt-webpack-plugin');
✗ import RobotstxtPlugin from 'robotstxt-webpack-plugin';
Plugin is exported as CommonJS default. For ESM, use the require or use default export workaround.
RobotstxtPlugin
✓ import RobotstxtPlugin from 'robotstxt-webpack-plugin';
Available as default export for ESM users.
default
✓ const { default: RobotstxtPlugin } = require('robotstxt-webpack-plugin');
✗ const RobotstxtPlugin = require('robotstxt-webpack-plugin').default;
In CJS, the default export is the plugin itself, not under .default. But due to ESM interop, some setups may need this pattern.

Configures webpack to output a robots.txt disallowing all crawlers.

const RobotstxtPlugin = require('robotstxt-webpack-plugin'); module.exports = { plugins: [ new RobotstxtPlugin({ // Generates a robots.txt that disallows all userAgent: '*', disallow: '/', }), ], };
Debug
Known issues
breakingMinimum supported webpack version is 5
fix
Upgrade webpack to version 5 or later.
affects: >=8.0.0
breakingMinimum supported Node.js version is 14.15.0
fix
Upgrade Node.js to version 14.15.0 or later.
affects: >=8.0.0
breakingIn version 5.0.0, the plugin was renamed from RobotstxtWebpackPlugin to RobotstxtPlugin
fix
Use the new class name RobotstxtPlugin instead of RobotstxtWebpackPlugin.
affects: >=5.0.0
deprecatedOld class name RobotstxtWebpackPlugin is no longer available
fix
Replace RobotstxtWebpackPlugin with RobotstxtPlugin.
affects: >=5.0.0
gotchaCommonJS require does not work as expected in some bundler setups
fix
Use const RobotstxtPlugin = require('robotstxt-webpack-plugin'); (default export directly).
affects: >=5.0.0
Errors
Common errors & fixes
Error: Cannot find module 'robotstxt-webpack-plugin'
Package not installed or not in node_modules.
fix
Run npm install --save-dev robotstxt-webpack-plugin
TypeError: RobotstxtWebpackPlugin is not a constructor
Using old class name RobotstxtWebpackPlugin which was renamed in v5.
fix
Use new class name RobotstxtPlugin.
Module not found: Error: Can't resolve 'generate-robotstxt'
Missing underlying dependency when using certain options.
fix
Ensure generate-robotstxt is installed: npm install generate-robotstxt
Upgrade
Version history
8.0.0latest on npm
Audit
Dependencies
webpackrequiredPeer dependency required for plugin to function
generate-robotstxtoptionalUnderlying package that generates the robots.txt content
Agent activity
4 hits · last 30 days
node
4
Resources
robotstxt-webpack-plugin — npm install robotstxt-webpack-plugin · libregistry