GDAX API ReferenceError: suite is not defined - javascript

I am new to node.js and I am trying to use the GDAX API. I downloaded all of the programs and followed the instructions. I have not edited any of the .js files and I am just trying to run one of the provided test files.
npm outdated has all dependencies with their Wanted version and npm list has all dependencies in the green as the tree structure.
I use node public_client.js to run the test file.
Note all of the code was cloned from a git repository.
Here is an image of the error:
ERROR (Not enough history to embed images)
Here is the error in terminal:
Alecs-MacBook-Pro:tests Alec$ node public_client.js
/Users/Alec/Documents/Trading/gdax-node/tests/public_client.js:9
suite('PublicClient');
^
ReferenceError: suite is not defined
at Object.<anonymous> (/Users/Alec/Documents/Trading/gdax-node/tests/public_client.js:9:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
Here are the first nine lines of the file:
var assert = require('assert');
var nock = require('nock');
var Gdax = require('../index.js');
var publicClient = new Gdax.PublicClient();
var EXCHANGE_API_URL = 'https://api.gdax.com';
suite('PublicClient');
Here is the index file:
var PublicClient = require('./lib/clients/public.js');
var WebsocketClient = require('./lib/clients/websocket.js');
var AuthenticatedClient = require('./lib/clients/authenticated.js');
var Orderbook = require('./lib/orderbook.js');
var OrderbookSync = require('./lib/orderbook_sync.js');
module.exports = exports = {
'PublicClient' : PublicClient,
'WebsocketClient' : WebsocketClient,
'AuthenticatedClient': AuthenticatedClient,
'Orderbook' : Orderbook,
'OrderbookSync' : OrderbookSync,
};

That package is using mocha to run the tests. They have a script entry ready for that, so just run npm test and voila.
The command is using is in the package.json:
"scripts": {
"test": "mocha --ui qunit --bail --reporter list tests/*.js"
}

Related

Why nodejs didnt require p-queue?

I want to use p-queue npm nodejs. But it get me error. Help me why it was and how to fix it? Here my code:
const shell = require("shelljs");
const async = require("async");
const fs = require("fs");
const path = require("path");
const { default: PQueue } = require("p-queue");
const queue = new PQueue({ concurrency: 1 });
And this error:
internal/modules/cjs/loader.js:1080
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module:
C:\Users\Feruz\Desktop\codeMaster\judge\node_modules\p-queue\dist\index.js
require() of ES modules is not supported. require() of
C:\Users\Feruz\Desktop\codeMaster\judge\node_modules\p-queue\dist\index.js
from C:\Users\Feruz\Desktop\codeMaster\judge\judge.js is an ES module
file as it is a .js file whose nearest parent package.json contains
"type": "module" which defines all .js files in that package scope as
ES modules. Instead rename index.js to end in .cjs, change the
requiring code to use import(), or remove "type": "module" from
C:\Users\Feruz\Desktop\codeMaster\judge\node_modules\p-queue\package.json.
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1080:13)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Users\Feruz\Desktop\codeMaster\judge\judge.js:5:29)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14) { code: 'ERR_REQUIRE_ESM' } [nodemon] app crashed - waiting for file
changes before starting...

firebase cloud function deploy glob error

When deploying my cloud functions using the command firebase deploy I am getting this error for all of my functions:
! functions[deleteGame-DeleteGameFunction(us-central1)]: Deployment error.
Function load error: Code in file index.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module 'glob'
at Function.Module._resolveFilename (module.js:476:15)
at Function.Module._load (module.js:424:25)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/user_code/index.js:11:14)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
This is my index.js file (I got it from here):
'use strict';
/** EXPORT ALL FUNCTIONS
*
* Loads all `.f.js` files
* Exports a cloud function matching the file name
* Author: David King
* Edited: Tarik Huber
* Based on this thread:
* https://github.com/firebase/functions-samples/issues/170
*/
const glob = require("glob");
const camelCase = require("camelcase");
const files = glob.sync('./**/*.f.js', { cwd: __dirname, ignore:
'./node_modules/**'});
for(let f=0,fl=files.length; f<fl; f++){
const file = files[f];
const functionName = camelCase(file.slice(0, -5).split('/').join('_')); //
Strip off '.f.js'
if (!process.env.FUNCTION_NAME || process.env.FUNCTION_NAME ===
functionName) {
exports[functionName] = require(file);
}
}
This index.js file is a way to organize your firebase cloud functions that I found on https://postmarkapp.com/blog/sending-transactional-emails-via-firebase-and-cloud-functions that got it from https://codeburst.io/organizing-your-firebase-cloud-functions-67dc17b3b0da
Thank you for your help!
It sounds like you need to run this from your functions directory:
npm install glob
And probably also
npm install camelcase
You can't require a module without first installing it into your project like this.

i have an error at nodejs with 'oracledb'

I have an error with oracledb modules.
I have successed to install oracledb.
when i typed like this,
-> npm install oracledb
njsOracle.cpp
njsPool.cpp
njsConnection.cpp
njsResultSet.cpp
njsMessages.cpp
njsIntLob.cpp
dpiEnv.cpp
dpiEnvImpl.cpp
dpiException.cpp
dpiExceptionImpl.cpp
dpiConnImpl.cpp
dpiDateTimeArrayImpl.cpp
dpiPoolImpl.cpp
dpiStmtImpl.cpp
dpiUtils.cpp
dpiLob.cpp
dpiCommon.cpp
win_delay_load_hook.cc
C:\Users\aaa\AppData\Roaming\npm\node_modules\oracledb\build\Release\oracledb.lib 라이브러리 및 C:\Users\aaa
\AppData\Roaming\npm\node_modules\oracledb\build\Release\oracledb.exp 개체를 생성하고 있습니다.
코드를 생성하고 있습니다.
코드를 생성했습니다.
oracledb.vcxproj -> C:\Users\aaa\AppData\Roaming\npm\node_modules\oracledb\build\Release\oracledb.node
oracledb.vcxproj -> C:\Users\aaa\AppData\Roaming\npm\node_modules\oracledb\build\Release\oracledb.pdb (Full PDB)
C:\Users\GwiTtaeGi\AppData\Roaming\npm
`-- oracledb#1.13.1
but when i execute require('oracledb'), there's an error like this.
Error: The specified procedure could not be found.
\?\c:\testnode\test\node_modules\oracledb\build\Release\oracledb.node
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (c:\testnode\test\node_modules\oracledb\lib\oracledb.js:35:19)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
I can't fix this error..
version is..
node -v : v6.10.3
npm -v : 4.5.0
Firstly, try to clean NPM cache
rm -rf ~/.node-gyp ~/.npm; npm cache clean
If error still occurs, try set NODE_PATH environment variable

Node and Require import error in Mocha?

I have a working Node application and I'm trying to add Mocha tests, but getting some odd import errors.
This is my file structure:
package.json
index.js
src/
chart.js
highcharts-options.js
test/
test_chart.js
This is what my chart.js file looks like:
var chartOptions = require('./highcharts-options');
var analyseChart = {
doSomething: function() { ... }
};
module.exports = analyseChart;
And this is what highcharts-options.js looks like:
var HighCharts = require('highcharts-browserify');
Highcharts.theme = { ... };
Currently I import everything from /src into a single index.js file, then bundle it with browserify, which works just fine, no errors in the application.
Now I want to start writing Mocha tests for the functions in /src.
This is my first stub in test_chart.js:
var chart = require('../src/chart');
chart.doSomething();
But when I run mocha, I get the following error:
Users/.../js/src/highcharts-options.js:11
Highcharts.theme = {
^
ReferenceError: Highcharts is not defined
at Object.<anonymous> (/Users/.../js/src/highcharts-options.js:11:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/.../js/src/chart.js:7:20)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/.../js/test/test_chart.js:1:75)
How can I fix this import error for Mocha?
var HighCharts = require('highcharts-browserify');
Highcharts.theme = { ... };
You have a spelling error.
High[cC]harts
How did you not notice this yourself even when you were told exactly what was wrong?
Some errors are so common that we ultimately stop trusting them, and start looking for other faults in our code without even investigating it.
This is especially true for the "someVar is undefined" error in javascript.
Takeaway:
Sometimes you just got to trust your error messages.

jasmineNodeOpts: Unexpected identifier error while executing protractor protractorConfig.js

This is my config.js file -
//server config information
var serverConfig=require('./serverConfig.js').serverConfig;
var $browser= serverConfig.$browser;
//got the browser name
process.argv.forEach(function (val, index) {
if(val==='-browser'){
$browser=process.argv[index+1];
}
});
// !!! update the server config
serverConfig.$browser= $browser;
//config
//browser.driver.manage().timeouts().setScriptTimeout(TIME_OUT);
// The main suite of Protractor tests.
exports.config = {
seleniumServerJar: '../../selenium/selenium-server-standalone-2.37.0.jar',
chromeDriver: '../../selenium/chromedriver.exe',
seleniumAddress: serverConfig.SELENIUMN_ADDRESS,
// Spec patterns are relative to this directory.
specs: [
'../e2e/Regression/CreateOperatorViewFromViewManagement.js'
],
capabilities: {
'browserName': $browser
},
onPrepare:'../prepareStartup.js',
//When the angular bootstrap not from the <html></html>
rootElement: 'body>div',
baseUrl: serverConfig.BASE_URL
jasmineNodeOpts: {
showColors: true, // Use colors in the command line report.
}
};
I get this error when I try to execute my tests using this config.js file -
C:\TRUNK\tests\func\gui\protractor\config\protractorConfig.js:60
jasmineNodeOpts: {
^^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at ConfigParser.addFileConfig (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\lib\configParser.js:139:20)
at Object.init (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\lib\launcher.js:59:7)
at Object.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\protractor\lib\cli.js:118:23)
at Module._compile (module.js:456:26)
When I execute protractor --help I get following options -
Options:
--help Print Protractor help menu
--version Print Protractor version
--browser, --capabilities.browserName Browsername, e.g. chrome or firefox
--seleniumAddress A running seleium address to use
--seleniumServerJar Location of the standalone selenium jar file
--seleniumPort Optional port for the selenium standalone ser
--baseUrl URL to prepend to all relative paths
--rootElement Element housing ng-app, if not html or body
--specs Comma-separated list of files to test
--exclude Comma-separated list of files to exclude
--verbose, --jasmineNodeOpts.isVerbose Print full spec names
--stackTrace, --jasmineNodeOpts.includeStackTrace Print stack trace on error
--params Param object to be passed to the tests
--framework Test framework to use. jasmine or mocha.
Please suggest what mistake I'm making in the config file or do I need to configure some more things.
You forgot a comma at the end of baseUrl: serverConfig.BASE_URL ;)
It should be:
baseUrl: serverConfig.BASE_URL,

Categories