Skip to content

SyntaxError: Unexpected token import, when import axios #54

Description

@Mcgrean0519

As I used 'const axios = require('axios');' in my javascript file.
When I build my Android application, the following error appeared.
/data/data/com.yourorg.sample/files/nodejs-project/node_modules/axios/index.js:1
(function (exports, require, module, __filename, __dirname) { import axios from './lib/axios.js';
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:588:28)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object. (/data/data/com.yourorg.sample/files/nodejs-project/demo.mjs:1:77)
But I had updated my node version and installed the axios by npm.
I really need to use axios library.
Does anyone know the reason? How can i fix it?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions