GithubHelp home page GithubHelp logo

blueandi / niu-cloud-cli Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 2.0 181 KB

NIU cloud command line interface for easy scripting.

License: MIT License

JavaScript 100.00%
niu cloud nodejs e-scooter

niu-cloud-cli's People

Contributors

blueandi avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

gablau liucoj

niu-cloud-cli's Issues

Error with Get Tracks - API change /v3/motor_data/track ?

I like your project !
I would like to have data of my Niu Scooter to integrate in Home Assistant
Your CLI is perfect but only on error on get-tracks
After many research, i think API have been change : /v3/motor_data/track/ respond an error...
Could you help me to find the new API point please, just the end point.
Thanks a lot !

Error when creating token file

Hi there,

is there a known problem with the communication protocol?
Main branch gave me some protocol errors, so I tried the development branch as it was more recent.
When I want to create the token file, I get the following error:

Internal error.
file:///home/openhabian/niu-cloud-cli-dev/src/createToken.js:100
        yargs().exit(errorCode.FAILED);
        ^

ReferenceError: yargs is not defined
    at file:///home/openhabian/niu-cloud-cli-dev/src/createToken.js:100:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.19.0

require() of ES Module not supported

When building with a current node Docker image, I got the following error:

/opt/niu-cloud-cli/libs/niu-cloud-connector/index.js:25
var got = require("got");
          ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /opt/niu-cloud-cli/node_modules/got/dist/source/index.js from /opt/niu-cloud-cli/libs/niu-cloud-connector/index.js not supported.
Instead change the require of /opt/niu-cloud-cli/node_modules/got/dist/source/index.js in /opt/niu-cloud-cli/libs/niu-cloud-connector/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/opt/niu-cloud-cli/libs/niu-cloud-connector/index.js:25:11) {
  code: 'ERR_REQUIRE_ESM'
}

This can be fixed by changing the above require to import got from 'got'; and adding "type": "module", to package.json.

However, the same error happens after that with require("yargs"); from niu-cloud-cli.js. Changing that to the import syntax then leads to a bunch of errors from yarn that are above my (very limited) js knowledge:

file:///opt/niu-cloud-cli/niu-cloud-cli.js:30
    .command(require("./src/createToken"))
    ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/opt/niu-cloud-cli/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///opt/niu-cloud-cli/niu-cloud-cli.js:30:5
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.