axios: [ERR_PACKAGE_PATH_NOT_EXPORTED] when trying to import anything from lib/helpers

Trying to import helper into my project:

import isAbsoluteURL from 'axios/lib/helpers/isAbsoluteURL'

Getting:

Module not found: Error: Package path ./lib/helpers/isAbsoluteURL is not exported from package /Users/.../node_modules/axios (see exports field in /Users/.../node_modules/axios/package.json)

Expected behavior

Was able to import the helper (used to work in 0.27)

Environment

  • Axios Version [1.1.2]
  • Node.js Version [16]

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 23
  • Comments: 32 (1 by maintainers)

Most upvoted comments

Just want to add my two cents to this. After struggling to find the reason for this error within my own code, I finally noticed that one of my other dependencies was using an old version of axios-cookiejar-support that was throwing this error. Updating that package fixed it for me.

Same issue. Any update?

Seeing similar with node.js ES6 modules, e.g.

import axios from 'axios'
import config from 'axios-debug-log'
...

Behaviour

At runtime,

...
"trace":["Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/helpers/isAbsoluteURL' is not defined by \"exports\" in /var/task/node_modules/axios/package.json","    at new NodeError (node:internal/errors:387:5)","    at throwExportsNotFound (node:internal/modules/esm/resolve:464:9)","    at packageExportsResolve (node:internal/modules/esm/resolve:748:3)","    at resolveExports (node:internal/modules/cjs/loader:493:36)","    at Function.Module._findPath (node:internal/modules/cjs/loader:533:31)","    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:942:27)","    at Function.Module._load (node:internal/modules/cjs/loader:804:27)","    at Module.require (node:internal/modules/cjs/loader:1028:19)","    at require (node:internal/modules/cjs/helpers:102:18)","    at Object.<anonymous> (/var/task/node_modules/axios-debug-log/index.js:4:21)"]}
...

Environment

Axios Version [1.1.2] Node.js Version [16]

Any update here? I’ve upgraded to the latest, and we’re seeing the same thing breaking all our builds.

From reading this thread, sounds like there are many issues in the same area. Any fix or work around in site?

On a second look isn’t exactly the same err, should I open a new ticket:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./lib/defaults’ is not defined by “exports” in /Users/salimbene/dev/hlp-bc-contracts-api/node_modules/axios/package.json [0] at new NodeError (node:internal/errors:372:5) [0] at throwExportsNotFound (node:internal/modules/esm/resolve:472:9) [0] at packageExportsResolve (node:internal/modules/esm/resolve:753:3) [0] at resolveExports (node:internal/modules/cjs/loader:482:36) [0] at Function.Module._findPath (node:internal/modules/cjs/loader:522:31) [0] at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27) [0] at Function.Module._load (node:internal/modules/cjs/loader:778:27) [0] at Module.require (node:internal/modules/cjs/loader:1005:19) [0] at require (node:internal/modules/cjs/helpers:102:18) [0] at Object.<anonymous> (/Users/salimbene/dev/hlp-bc-contracts-api/node_modules/axios-cookiejar-support/lib/index.js:8:40) { [0] code: 'ERR_PACKAGE_PATH_NOT_EXPORTED

Any updates on this issue?