Skip to content

The requested module 'webpack-subresource-integrity' is a CommonJS module #231

Description

@marekdedic

Hi,
I'm trying to switch a project to "type": "module", so I converted my webpack.config.js to include the following import:

import { SubresourceIntegrityPlugin } from "webpack-subresource-integrity";

However, I am getting the following error:

[webpack-cli] Failed to load '/home/user/project/webpack.config.js' config
[webpack-cli] file:///home/user/project/webpack.config.js:6
import { SubresourceIntegrityPlugin } from "webpack-subresource-integrity";
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'SubresourceIntegrityPlugin' not found. The requested module 'webpack-subresource-integrity' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'webpack-subresource-integrity';
const { SubresourceIntegrityPlugin } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
    at async WebpackCLI.tryRequireThenImport (/home/user/project/node_modules/webpack-cli/lib/webpack-cli.js:232:34)
    at async loadConfigByPath (/home/user/project/node_modules/webpack-cli/lib/webpack-cli.js:1406:27)
    at async WebpackCLI.loadConfig (/home/user/project/node_modules/webpack-cli/lib/webpack-cli.js:1515:38)
    at async WebpackCLI.createCompiler (/home/user/project/node_modules/webpack-cli/lib/webpack-cli.js:1781:22)
    at async WebpackCLI.runWebpack (/home/user/project/node_modules/webpack-cli/lib/webpack-cli.js:1877:20)
    at async Command.<anonymous> (/home/user/project/node_modules/webpack-cli/lib/webpack-cli.js:944:21)
    at async Command.parseAsync (/home/user/project/node_modules/webpack-cli/node_modules/commander/lib/command.js:935:5)

See marekdedic/prosemirror-remark-example#3

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions