Skip to content

proxy-from-env is expected to be of type CommonJS, which does not support named exports.  #5221

@pavan168

Description

@pavan168

Describe the bug

I have a NextJs app with axios version 1.1.3 and recently i've updated webpack to version 5 from version 4.

I think with webpack 5, importing named exports from certain packages don't work. I thought it's only JSON modules. Anyhow, I picked this up from here https://webpack.js.org/blog/2020-10-10-webpack-5-release/

At the same time, this issue works fine on macOS.

To Reproduce

No response

Code snippet

import {getProxyForUrl} from 'proxy-from-env';
        ^^^^^^^^^^^^^^
SyntaxError: The requested module 'proxy-from-env' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from 'proxy-from-env';
const {getProxyForUrl} = pkg;
    at ModuleJob._instantiate (internal/modules/esm/module_job.js:98:21)
    at async ModuleJob.run (internal/modules/esm/module_job.js:137:5)
    at async Loader.import (internal/modules/esm/loader.js:165:24)
file:///N:/laeb/p2/la3eb-web/node_modules/axios/lib/adapters/http.js:7
import {getProxyForUrl} from 'proxy-from-env';
        ^^^^^^^^^^^^^^
        ^^^^^^^^^^^^^

Expected behavior

'proxy-from-env' package in lib/adapters/http.js should be default imported.

Axios Version

1.1.3

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

14.17

OS

Windows 10 Pro, version 22H2

Additional Library Versions

No response

Additional context/Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions