canirequire

canirequire › CommonJS › @webcomponents/webcomponentsjs

Is @webcomponents/webcomponentsjs ESM-only? Can you require() it?

Web Components Polyfills

Last verified Sep 9, 2026 against @webcomponents/webcomponentsjs@2.8.0. Markdown · JSON

CommonJS CommonJS on paper — require() failed in our runtime test

@webcomponents/webcomponentsjs declares a CommonJS entry only, but require("@webcomponents/webcomponentsjs") failed on every Node.js version in our probe: ReferenceError: window is not defined. import "@webcomponents/webcomponentsjs" resolves to the same file, so it fails the same way. That usually means a missing peer dependency, a browser-only global, or a package that is not meant to be loaded directly; see the runtime table below.

What to do

  1. require("@webcomponents/webcomponentsjs") failed in our probe on every Node.js version (ReferenceError: window is not defined); check the package README for peer dependencies or setup before relying on it.
  2. From ES modules use the default import: import webcomponentsjs from "@webcomponents/webcomponentsjs"; then destructure. Named imports only work when Node.js can statically detect the exports.
  3. TypeScript: types are bundled; install nothing extra.
Latest
2.8.0 (Mar 30, 2023)
Module format
CommonJS
Last CommonJS version
2.8.0
TypeScript types
Bundled
Node engines
not declared
Weekly downloads
259K
License
BSD-3-Clause

Does @webcomponents/webcomponentsjs@2.8.0 actually load? Runtime test results

Installed and executed on Sep 9, 2026 with require("@webcomponents/webcomponentsjs") from a CommonJS file and import "@webcomponents/webcomponentsjs" from an ES module.

Runtimerequire("@webcomponents/webcomponentsjs")import "@webcomponents/webcomponentsjs"
Node.js 18✗ failsReferenceError✗ failsReferenceError
Node.js 20✗ failsReferenceError✗ failsReferenceError
Node.js 22✗ failsReferenceError✗ failsReferenceError
Node.js 24✗ failsReferenceError✗ failsReferenceError
Node.js 26✗ failsReferenceError✗ failsReferenceError
Bun 1.4.0✗ failsReferenceError✗ failsReferenceError

A failing require() on a CommonJS package usually means the package needs a browser/DOM global, a peer dependency, or a native binary that is not available in a bare Node.js process.

How to import @webcomponents/webcomponentsjs

ES modules (import)

import webcomponentsjs from "@webcomponents/webcomponentsjs";

Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.

CommonJS (require)

// require("@webcomponents/webcomponentsjs") failed in our probe on every Node.js version we test (ReferenceError: window is not defined); see the runtime table.
const webcomponentsjs = require("@webcomponents/webcomponentsjs");

Module format by version

Derived from the type, main and exports fields of every stable release on npm, corrected where a runtime test of that version contradicted them (65 versions; the newest 60 shown).

VersionsFormatFirst published
1.0.6 – 2.8.0CommonJSAug 7, 2017

Frequently asked

Is @webcomponents/webcomponentsjs ESM-only?

@webcomponents/webcomponentsjs@2.8.0 declares a CommonJS entry, but require() fails at runtime. @webcomponents/webcomponentsjs declares a CommonJS entry only, but require("@webcomponents/webcomponentsjs") failed on every Node.js version in our probe: ReferenceError: window is not defined. import "@webcomponents/webcomponentsjs" resolves to the same file, so it fails the same way. That usually means a missing peer dependency, a browser-only global, or a package that is not meant to be loaded directly; see the runtime table below.

Can I require @webcomponents/webcomponentsjs?

Not in practice. @webcomponents/webcomponentsjs declares a CommonJS entry, but require("@webcomponents/webcomponentsjs") failed on every Node.js version in our probe: ReferenceError: window is not defined. Check the package README for peer dependencies or setup before relying on it.

Can I import @webcomponents/webcomponentsjs with ES module syntax?

Yes. import webcomponentsjs from "@webcomponents/webcomponentsjs" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.

Does @webcomponents/webcomponentsjs work in Bun?

Importing @webcomponents/webcomponentsjs failed in Bun 1.4.0 on Sep 9, 2026: ReferenceError: window is not defined

Does @webcomponents/webcomponentsjs ship TypeScript types?

Yes. @webcomponents/webcomponentsjs bundles its own type declarations; no @types package is needed.

Links

Other commonjs packages

Similar popularity