question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with: const ccxt = require('ccxt');

See original GitHub issue
  • OS: Windows 10
  • Programming Language version: Visual Studio 2017 (Universal Windows Javascript App)
  • CCXT version: #465
  • Exchange: Bitfinex
  • Node.js 11.9.0 installed
  • Method: const ccxt = require(‘ccxt’);

Hello!

I succeed to return all exchanges in chrome console with below code: console.log(ccxt.exchanges);

But I think that I don’t want to run the library in a browser. But instead in Visual Studio Debugger. Now comes the problem. When I run it in the debugger instead and NOT in a browser, I receive below commented error.

So const ccxt = require(‘ccxt’); seems to have a problem here because ‘require’ is not defined somehow. I don’t know how to implement this correctly? Please see more comments in the code snippets below. _(In the 3rd codesnippet with the ‘CORS’ error is the reason I want to Not run it in a browser but Visual Studio directly because as I understood it this can then be avoided?)

            //const Exchange = require('./js/base/Exchange')
            //Unhandled exception at line 33, column 1 in ms - appx://6b49fdc7-ae95-44f8-9223-0bfbb5025163/ccxt-master/ccxt.js
            //0x800a1391 - JavaScript runtime error: 'require' is not defined
            const ccxt = require('ccxt');

COMPLETE CODE WITH COMMENTS ABOVE EACH TO UNDERSTAND WHAT I HAVE TRIED `<body onload="myFunction();"> <script src="ccxt-master/ccxt.js"></script> <script src="js/require.js"></script> <script type="text/javascript" src="https://unpkg.com/ccxt"></script> <script type="text/javascript"> function myFunction() {

            //This code returns this error when NOT running in a browser (But running in Visual Studio directly)
            //const Exchange = require('./js/base/Exchange')
            //Unhandled exception at line 33, column 1 in ms - appx://6b49fdc7-ae95-44f8-9223-0bfbb5025163/ccxt-master/ccxt.js
            //0x800a1391 - JavaScript runtime error: 'require' is not defined
            const ccxt = require('ccxt');

            /*-------------------------------------------------------------*/
            //This code returns all exchanges in chrome console
            console.log(ccxt.exchanges);

            /*-------------------------------------------------------------*/
            //This code returns this error in chrome console
            //Access to fetch at 'https://api.bitfinex.com/v1/symbols_details' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin'
            //header is present on the requested resource.If an opaque response serves your needs, set the request's mode to 'no - cors' 
            //to fetch the resource with CORS disabled.
            let exchange = new ccxt.bitfinex();
            exchange.verbose = true;
            console.log(exchange.loadMarkets());
    }
</script>
</body>`

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jackpotcitycocommented, Feb 11, 2019

Thank you kroitor, that was a big help. Then I know where to start so I am in the correct environment with all javascript etc.

0reactions
kroitorcommented, Feb 11, 2019

Is this where the coding should take place when using NPM/Node.js ?

Yes, basically, you should search for “how to start programming with Node.js” tutorials. The link you posted should help. However, I’d also recommend these:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Install — ccxt 2.4.43 documentation
The problem with in-browser usage is that the entire CCXT library weighs a few megabytes which ... const ccxt = require ('ccxt') ,...
Read more >
ccxt · PyPI
The CCXT library is used to connect and trade with cryptocurrency exchanges ... 'use strict'; const ccxt = require ('ccxt'); (async function ()...
Read more >
Top 5 ccxt Code Examples - Snyk
To help you get started, we've selected a few ccxt examples, based on popular ways it is used in public projects. Secure your...
Read more >
Highest scored 'ccxt' questions - Page 3 - Stack Overflow
Later, I added this line to a script: const ccxt = require ('ccxt'); And .. ... CCXT balance = binanceus.fetch_balance() python problems.
Read more >
CCXT Pro - A JavaScript / Python / PHP cryptocurrency trading ...
'use strict'; const ccxtpro = require ('ccxt.pro'); (async () => { const exchange = new ccxtpro.binance ({ enableRateLimit: true }) while (true) {...
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