Latest release of axios throws SyntaxError: Unexpected identifier

See original GitHub issue

Describe 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:closed
  • Created a year ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
nicoContiglianicommented, Oct 14, 2022

I solved the error. I used an older version - npm i axios@0.21

4reactions
david-littlefieldcommented, Nov 28, 2022

npm i axios@1.2.0-alpha.1 didn’t work for me npm i axios@0.21 did work for me

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found