Comments (6)
Just in case anyone else hits this. I am using Node v14.18.2 with the mjs extension to use ES6 imports. The examples all show import otaClient from '@crowdin/ota-client';
however upon trying to create a new object it failed since this does not make otaClient a constructor. I instead had to end up doing const client = new otaClient.default(hash);
.
Upon logging, you will see the default example creating an object with the default property containing the constructor. The import rename syntax also does NOT work here, import {default as otaClient} from '@crowdin/ota-client';
. This still makes otaClient the object with a default property.
Could be a bug in Node or a general issue with packaging modules. Just a note here in case anyone else comes across this with es6 module imports too.
from ota-client-js.
@ferreiro hi there! Could you please share the part of code with the import/require statement? And also would be nice to know which version of the library you are using. Thanks!
from ota-client-js.
It looks to me that problem is not in Node itself but rather in wrong import of OtaClient
from ota-client-js.
hey @yevheniyJ sorry for the delay :/ I've tried several things:
const otaClient = require('@crowdin/ota-client');
console.log(otaClient);
const hash = '{distribution_hash}';
const client = new otaClient(hash);
// get list of files in distribution
client
.listFiles()
.then(files => console.log(file))
.catch(error => console.error(error));
const {otaClient} = require('@crowdin/ota-client');
console.log(otaClient);
const client = new otaClient('{distribution_hash}');
// get list of files in distribution
client
.listFiles()
.then(files => console.log(file))
.catch(error => console.error(error));
both of them produced the same error...
However, I figured out how to make it work...
const otaClient = require('@crowdin/ota-client');
const client = new otaClient.default('{distribution_hash}');
so I needed to use otaClient.default
, so the instructions in the readme are wrong. Can you update this to work for this:
const otaClient = require('@crowdin/ota-client');
const client = new otaClient.default(hash);
from ota-client-js.
@ferreiro hi hi!) good that you found solution. I suggest to move default
suffix to the require section. So in the end you should have smth like this : const otaClient = require(β@crowdin/ota-clientβ).default;
and later on create an instance without default
keyword. In my eyes it is more understandable π
from ota-client-js.
And in readme we are using ES6 import/export syntax and it is correct. I will just add another example with Node.js require
option.
from ota-client-js.
Related Issues (8)
- Calling getTranslations() throws an error due to multiple English translations HOT 1
- Trowing error: Unsupported language code with custom languages and url placeholders HOT 1
- Proposal: get language list from Crowdin API HOT 8
- File Settings path missing starting slash issue HOT 3
- Crowdin ota-client with i18next using React with Typescript is not working HOT 1
- Axios error with newest version HOT 7
- Some translations are missing from my project HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ota-client-js.