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)
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.
Behaviour
At runtime,
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
It’s worked @Mifrill
Demo code (js version): https://codesandbox.io/p/sandbox/new-wildflower-m3znw4?file=%2Fsrc%2FApp.js%3A10%2C11
TS version: https://codesandbox.io/p/sandbox/lucid-cloud-forked-4fhnzx?file=%2Fsrc%2FApp.tsx%3A12%2C5
Any updates on this issue?