liferay-frontend-projects icon indicating copy to clipboard operation
liferay-frontend-projects copied to clipboard

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

Open myou11 opened this issue 2 years ago • 3 comments

Issue type

  • [x] :bug: 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):

myou11 avatar Nov 22 '22 19:11 myou11

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

izaera avatar Nov 24 '22 07:11 izaera

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

mrtipsytony avatar Mar 15 '24 09:03 mrtipsytony

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...

izaera avatar Mar 20 '24 07:03 izaera