liferay-frontend-projects
liferay-frontend-projects copied to clipboard
cannot import axios v1.0.0 and up in Liferay Platform project
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
- I used
-
yarn add axios
- add
import axios from "axios"
inAppComponent.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):
[NOTE: This bug is being tracked as https://issues.liferay.com/browse/LPS-169494 internally]
Any updates here? We're also using Axios in our project and would like to upgrade it too.
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...