Latest release of axios throws SyntaxError: Unexpected identifier
See original GitHub issueDescribe the bug
Started getting the following error yesterday.
/usr/src/app/node_modules/axios/index.js:1
import axios from './lib/axios.js';
^^^^^
SyntaxError: Unexpected identifier
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/usr/src/app/api/vendors/snd/SNDClient.js:1:15)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
Axios version in package.json was : >=0.23.0.
The issue went away when I switched to version 1.0.0-alpha.1.
I verified that I was using require to import axios in my code instead of import.
To Reproduce
Use latest version of axios in package.json
"axios": "1.0.0",
Expected behavior
In an ideal world, the nodejs app would have started without error.
Environment
- Axios Version 1.0.0
- Node.js Version 12.0.0
- OS: Debian GNU/Linux 9 (stretch) (EKS)
- Additional Library Versions: restify: 8.6.1
Additional context/Screenshots
N/A
Issue Analytics
- State:
- Created a year ago
- Comments:11 (1 by maintainers)
Top Results From Across the Web
SyntaxError: Unexpected identifier with axios - Stack Overflow
The node version is v10.4.0 . With var axios = require('axios'); it works. But I need with import . – ...
Read more >import axios from './lib/axios.js'; ^^^^^ syntaxerror: unexpected identifier
Latest release of axios throws SyntaxError: Unexpected identifier ... Github.com > axios > axios. Axios version in package.json was : >=0.23.0. The issue ......
Read more >SyntaxError: Unexpected token import in Node.js | bobbyhadz
The "SyntaxError: Unexpected token import" occurs when we use the ES6 import syntax in a version of Node that doesn't support it. To...
Read more >Unexpected token error after adding await keyword to Node.js ...
Fairly new to the world of javascript, but learning quickly. Anyone have an idea why I'm getting a syntax error on this line?...
Read more >Fix 'Unexpected token o in json at position 1' - STechies
How to fix the 'Uncaught SyntaxError: Unexpected token o in JSON at position 1'. If a JSON string is already parsed in a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I solved the error. I used an older version - npm i axios@0.21
npm i axios@1.2.0-alpha.1didn’t work for menpm i axios@0.21did work for me