Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error trying to import deriv-api #21

Open
guilhermelionzo opened this issue Apr 22, 2020 · 3 comments
Open

Error trying to import deriv-api #21

guilhermelionzo opened this issue Apr 22, 2020 · 3 comments

Comments

@guilhermelionzo
Copy link

guilhermelionzo commented Apr 22, 2020

Hi there,

I'm trying to import deriv-api, but I'm receving the following error message:

> [email protected] start C:\Users\User\vscode-workspace\binarybot
> node index.js

file:///C:/Users/User/vscode-workspace/binarybot/index.js:4
import DerivAPI from '@deriv/deriv-api';
       ^^^^^^^^
SyntaxError: The requested module '@deriv/deriv-api' does not provide an export named 'default'
    at ModuleJob._instantiate (internal/modules/esm/module_job.js:92:21)
    at async ModuleJob.run (internal/modules/esm/module_job.js:107:20)
    at async Loader.import (internal/modules/esm/loader.js:179:24)

I ran the code below using NodeJs v14.0.0 and v13.5.

Could you guys help me?

import express from 'express';
import cors from 'cors';
import routes from './routes.js';
import DerivAPI from '@deriv/deriv-api';

var app = express();
var router = express.Router()

app.use(cors());
app.use(express.json());

router.get('/', function (req, res) {
    res.send('ROOT FOLDER')
  })

app.use(routes);
app.listen(3333, () => {
    console.log('debug > console listening on port 3333');
});

If you guys need more information, please, let me know.

@BrunoEmerich
Copy link

Hello my friend!!!

This error may occur because the require() isnt defined for the client-side!! Try to use the import {variables} from "YourModule" instead to see if it works.

Another option is put as top level of your package.json the type resolution as module:

{ "type": "module" }

The import statement if the default module resolution on ECMAScript 6.

I hope this solve your problem.

@guilhermelionzo
Copy link
Author

Hello my friend!!!

This error may occur because the require() isnt defined for the client-side!! Try to use the import {variables} from "YourModule" instead to see if it works.

Another option is put as top level of your package.json the type resolution as module:

{ "type": "module" }

The import statement if the default module resolution on ECMAScript 6.

I hope this solve your problem.

Hi @BrunoEmerich ,

Thank you for your reply my friend 😄

I've made a mistake and sent the wrong error message and code. I just updated the issue description.

My package.json have { "type": "module" } and all the external modules/libs are imported using import {variables} from "YourModule".

Unfortunately the error:
The requested module '@deriv/deriv-api' does not provide an export named 'default'

Probably I'm doing something wrong.

@salar-fs
Copy link

@guilhermelionzo Is the issue resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants