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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import axios v1.0.0 and up in Liferay Platform project #1047

Open
1 task done
myou11 opened this issue Nov 22, 2022 · 3 comments
Open
1 task done

cannot import axios v1.0.0 and up in Liferay Platform project #1047

myou11 opened this issue Nov 22, 2022 · 3 comments

Comments

@myou11
Copy link

myou11 commented Nov 22, 2022

Issue type

  • 馃悰 Bug report

Description

Axios v1.0.0 and up causes the React app to not work. It appears to be an import/export issue. If I have the axios import in the file, this error appears: Uncaught SyntaxError: import declarations may only appear at top level of a module. However, if i remove the axios import, then the error does not appear.

Desired behavior:
Be able to import Axios v1.0.0 and up

Current behavior:
Importing Axios v1.0.0 and up causes the React app to not load

Repro instructions (if applicable):

  • Create a Liferay Platform project following the instructions here
    • I used npx @liferay/cli new new-project-name
  • yarn add axios
  • add import axios from "axios" in AppComponent.js
  • yarn deploy
  • see Uncaught SyntaxError: import declarations may only appear at top level of a module in the console

Other information (environment, versions etc):

@izaera
Copy link
Member

izaera commented Nov 24, 2022

[NOTE: This bug is being tracked as https://issues.liferay.com/browse/LPS-169494 internally]

@mrtipsytony
Copy link

mrtipsytony commented Mar 15, 2024

Any updates here? We're also using Axios in our project and would like to upgrade it too.

@izaera
Copy link
Member

izaera commented Mar 20, 2024

Not really, because unfortunately we haven't had time to reproduce it.

Definitely more information to make a good diagnostic of what is causing the error would be helpful and make things go faster. Seeing the error it looks like the tool is using a JS file from axios that is not intended to be used in the browser. That is usually due to browser field configuration or something similar...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants