Skip to content

TypeError loading webpack.config.js in ESM project with node v16.6 #2864

Closed
@olizilla

Description

@olizilla

I think this change nodejs/node#39175 in node 16.6 means the webpack.config.js is loading is broken for ESM projects.

Our CI started failing once node 16.6 got rolled out with:

$ npm run build

> @web3-storage/api@3.1.1 build
> webpack

TypeError: String.prototype.startsWith called on null or undefined
    at startsWith (<anonymous>)
    at node:internal/errors:811:19
    at Array.filter (<anonymous>)
    at node:internal/errors:809:16
    at prepareStackTrace (node:internal/errors:96:12)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:38)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)

Setting WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG=true fixed it, but it seems like a workaround.

see:

(error.code === "ERR_REQUIRE_ESM" ||
process.env.WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG) &&

see: nodejs/node#39175
see: nodejs/node@e2a6399#r54198959

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions