Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The AxiosTransport of the DirectusSDK produces error: 'TypeError: axios_1.default.create is not a function' #7538

Closed
3 tasks done
rdytogokev opened this issue Aug 22, 2021 · 2 comments

Comments

@rdytogokev
Copy link

Preflight Checklist

Describe the Bug

I am trying to follow the instructions for installing and using the SDK as stated in the documentation. While I don't think the error is related, I should point out that I am trying to use the SDK in a SvelteJS app using the Routify router and starter template.

To Reproduce

(1) From the terminal, create a new folder to hold your app.
md testsdkwithsvelte

(2) From the terminal, navigate to your new folder.
cd testsdkwithsvelte

(3) From the terminal, install the Svelte Routify Starter Template.
npx @roxi/routify init

(4) From the terminal, install the Directus SDK.
npm install @directus/sdk

(5) Edit the main App component file (testsdkwithsvelte\src\App.svelte) to use the SDK.

<script>
  import { Router } from "@roxi/routify";
  import { routes } from "../.routify/routes";
  import { Directus } from '@directus/sdk';

  const directus = new Directus('http://localhost:8055');
</script>

<style  global>
  @import "../assets/global.css";
</style>

<Router {routes} />

(6) From the terminal, try to run the App.
npm run dev

(7) Once the app is running, In the browser, visit localhost:5000. You will see error in two ways: (1) a pretty print of the error overlaying the page and (2) in the console.

The console error should look something like the included image.
Screen Shot 2021-08-21 at 6 41 18 PM

What version of Directus are you using?

v9.0.0-rc.90

What version of Node.js are you using?

16.3.0

What database are you using?

SQLite3 5.0.2

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying Directus?

running locally

@rdytogokev rdytogokev changed the title The AxiosTransport of the DirectSDK produces error: 'TypeError: axios_1.default.create is not a function' The AxiosTransport of the DirectusSDK produces error: 'TypeError: axios_1.default.create is not a function' Aug 22, 2021
@rdytogokev
Copy link
Author

Update: The discussion related to this on the Directus Discord #SDK channel has led me to believe that the problem might be a conflict with the SDK and the Rollup bundler. One of the other members said that when they use the Vite bundler, the problem does not exist. If this issue gets fixed, it will probably help all users of the Rollup bundler to use Directus. Because I now have a workaround using Vite, there is no rush for me personally to have this fixed. However, I ask that you do consider keeping this issue open and resolving this for Rollup users at your convenience. Thanks.

AzraeL --
additional info: I tried out Routify + Vite 
(https://github.com/lamualfa/routify-vite) 
and directus works as well so I'm fairly 
certain it's a bundler related issue```

@rijkvanzanten
Copy link
Member

As far as I can tell, the exports of the SDK are defined correctly:

"main": "./dist/index.js",
"module": "./dist/sdk.esm.js",
"unpkg": "./dist/sdk.esm.min.js",
"types": "./dist/index.d.ts",
"exports": {
".": "./dist/index.js"
},

(though to be honest, npm's resolution, and the whole mess that is moving from CJS to ESM in Node doesn't make this any easier)

What was the specific rollup configuration used that failed?

In the meantime, with the exports seemingly looking correct, no clear direction on what to change to make it work, and the problem only happening on a single bundler with a specific configuration, I'll have to close this as something we can't actively fix

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants