plaid connect to client with node error - javascript

I'm using node backend and am trying to connect to plaid.
My code:
var plaid = require('plaid');
var clientID = "bla";
var secretID = "bla";
var publicKey = "bla";
var client = new plaid.Client(
clientID,
secretID,
publicKey,
plaid.environments.sandbox
);
However I am getting this error in my console:
throw new Error('Invalid Plaid environment');
^
Error: Invalid Plaid environment
at new Plaid.Client (C:\Users\me\Documents\found\SPA\node_modules\plaid\index.js:26:11)
at module.exports (C:\Users\me\Documents\found\SPA\app\routes.js:48:22)
at Object.<anonymous> (C:\Users\me\Documents\found\SPA\server.js:48:24)
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:394:7)
I have tried using each of these with no luck:
plaid.environments.sandbox
plaid.environments.development
plaid.environments.tartan
What's going on?
Ref: https://plaid.com/docs/quickstart/#accessing-item-data
UPDATE:
I've gotten this code below to work in another part of my app:
var plaidClient = new plaid.Client(clientID, secretID, plaid.environments.tartan);
However I am trying to use client.getTransactions() and it is required to have var plaidClient = new plaid.Client(clientID, secretID, publicID, plaid.environments.sandbox);
in order for client.getTransactions() to work.
UPDATE?

For some reason I had the wrong version of plaid installed. I needed to uninstall and reinstall to fix. Works now.

Related

Can't use a class defined in an npm package

I am trying to use a typescript-parser:
https://www.npmjs.com/package/typescript-parser
but I'm having difficulties with using the package properly.
I installed the package successfully using npm install; when I run npm list --depth=0 it shows up in the list.
Eventually, I tried running the following line of code that is suggested in the link attached above (using node command):
const parser = new TypescriptParser();
but the problem is that I get the following error:
const parser = new TypescriptParser();
^
ReferenceError: TypescriptParser is not defined
at Object.<anonymous> (C:\Users\...\parser_example.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Alternatively, I tried running this:
const TypescriptParser = require('typescript-parser');
const parser = new TypescriptParser();
yet I still get a (different) error:
const parser = new TypescriptParser();
^
TypeError: TypescriptParser is not a constructor
at Object.<anonymous> (C:\Users\...\parser_example.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
It seems as if although the package was installed, it doesn't recognize the class TypescriptParser.
Any help would be much appreciated!
Try importing using:
import { TypescriptParser } from 'typescript-parser';
I tried the code below and it works for me :
index.js file
const parser = require('typescript-parser');
const parser = new TypescriptParser();
I run it with node index.js
This code works for me:
index.js file
const tp = require('typescript-parser');
const parser = new tp.TypescriptParser();

"TypeError: jsdom.jsdom is not a function" with paper-node.js in npm paper module

I have installed webppl-agents library (along with webppl and webppl-dp) and am trying to run the command line test, but I'm running into some trouble. It appears there is a dependency issue with jsdom from the npm paper module (1) (2) (3) (4), but I haven't been able to get a complete handle on the issue at this point.
Does anybody know what's going on here? Do I just need to use a newer version of paper?
PS C:\Users\user\.webppl\node_modules\webppl-agents> webppl --require webppl-dp --require . tests/tests.wppl
C:\Users\user\.webppl\node_modules\webppl-agents\node_modules\paper\dist\paper-node.js:10835
document = jsdom.jsdom('<html><body></body></html>'),
^
TypeError: jsdom.jsdom is not a function
at new <anonymous> (C:\Users\user\.webppl\node_modules\webppl-agents\node_modules\paper\dist\paper-node.js:10835:19)
at Object.<anonymous> (C:\Users\user\.webppl\node_modules\webppl-agents\node_modules\paper\dist\paper-node.js:33:13)
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.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\user\.webppl\node_modules\webppl-agents\src\visualization\gridworld.js:1:75)
There has been some breaking changes recently. The following way of initializing jsodm, document and window fixed it for me:
import jsdom from 'jsdom';
const {JSDOM} = jsdom;
const {document} = (new JSDOM('<!doctype html><html><body></body></html>')).window;
global.document = document;
global.window = document.defaultView;

TypeError: Invalid connection Details (PG-Promise)

So I'm trying to solve an issue that PG-Promise is giving me, but I'm not entirely certain as to why. I'm very certain that I set up the database and environment for it correctly, and have properly seeded and tested the database locally. If needed be, I can link the respective queries I have that make calls to the database, but I'm not sure if that'll help solve this.
That said, below is the pg-promise environment and the exact error it's firing. I appreciate any help with solving this!
const promise = require('bluebird');
promise object has .catch/,then etc..
const options = {
promiseLib: promise
};
const pgp = require('pg-promise')(options);
const connectionString = process.env.DATABASE_URL;
my .env's database url is the following: DATABASE_URL=postgres://localhost:5432/project3//
const db = pgp(connectionString);
db.connect()
.then(obj => {
obj.done();
})
.catch(error => {
console.log('ERROR:', error.message || error);
});
TypeError: Invalid connection details.
at inst (/Users/benjidurden/Documents/projects/mighty-shelf-36224/node_modules/pg-promise/lib/main.js:177:15)
at Object.<anonymous> (/Users/benjidurden/Documents/projects/mighty-shelf-36224/routes/queries2.js:12:12)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/benjidurden/Documents/projects/mighty-shelf-36224/routes/index.js:4:10)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
If you just look at the code, then it is obvious that your process.env.DATABASE_URL is either null or an empty string, neither of which is a valid connection string, hence the error.
my .env's database url is the following: DATABASE_URL=postgres://localhost:5432/project3
You presume so, but I'm betting that it is not.
UPDATE
Following this question, I have refactored the initialization errors in pg-promise, to include the details of what is in fact being passed in, available from v5.7.2.

Node.js ERROR Cannot find Module

Hey guys I'm new to JS and Node.js and I'm having trouble setting up a webdriverio project using cucumber and PageObject. And every time I try to run a test this error happens:
ERROR: Cannot find module '../support/action/openWebsite'
chrome
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/axelbarford/Desktop/Oktana-training-webdriverio/src/steps/LoginStepDef/loginStepsDef.js:1:1)
at Module._compile (module.js:570:32)
at loader (/usr/local/lib/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
This is the loginStepsDef.js file where the openWebSite is being called:
import openWebsite from '../support/action/openWebsite';
import LoginPage from '../pageobject/LoginPage/LoginPage';
module.exports = function given() {
this.Given(
/^I open salesforce login page$/,
openWebsite
);
this.When(
/^I set user "([^"]*)?" and password "([^"]*)?"$/, function(arg1,arg2) {
LoginPage.open();
LoginPage.username.setValue(arg1)
LoginPage.password.setValue(arg2)
});
this.And(
/^I click the login button$/,function(){
LoginPage.open();
LoginPage.submit();
});
}
Any idea what could be happening would be great. Do you need me to show something more let me know.
Try with this :
var openWebsite = require('../../support/action/openWebsite');
var LoginPage = require('../../pageobject/LoginPage/LoginPage');

Unable to launch Firefox in selenium 3.0-beta3 with geckodriver 0.10 using Javascript with selenium's own sample

just want to learn Selenium testing beginning with it's own sample.
However, after everything is set up(Node.js, Selenium), when I want to use selenium-webdriver's own sample, it is not working:
This is the official code(name is google_search.js) provided by selenium:
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder()
.forBrowser('firefox')
.build();
driver.get('http://www.google.com/ncr');
driver.findElement(By.name('q')).sendKeys('webdriver');
driver.findElement(By.name('btnG')).click();
driver.wait(until.titleIs('webdriver - Google Search'), 1000);
driver.quit();
This code is within example folder, in Node.js cmd, I cd to node_modules\selenium-webdriver\example, and put geckodriver in this folder, then run node google_search.js
Here's the result:
C:\Users\username\node_modules\selenium-webdriver\lib\promise.js:2291
throw error;
^
WebDriverError: Unable to parse new session response: {"error":"unknown error","
message":"Expected browser binary location, but unable to find binary in default
location, no 'firefox_binary' capability provided, and no binary flag set on th
e command line"}
at WebDriverError (C:\Users\username\node_modules\selenium-webdriver\lib\err
or.js:27:10)
at C:\Users\username\node_modules\selenium-webdriver\lib\http.js:335:17
at process._tickCallback (node.js:369:9)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Users\username\node_modules\selenium-webdriver
\lib\webdriver.js:366:24)
at createGeckoDriver (C:\Users\username\node_modules\selenium-webdriver\fire
fox\index.js:497:27)
at Driver (C:\Users\username\node_modules\selenium-webdriver\firefox\index.j
s:605:14)
at Builder.build (C:\Users\username\node_modules\selenium-webdriver\index.js
:557:16)
at Object.<anonymous> (C:\Users\username\node_modules\selenium-webdriver\exa
mple\google_search.js:44:6)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
From: Task: WebDriver.navigate().to(http://www.google.com/ncr)
at Driver.schedule (C:\Users\username\node_modules\selenium-webdriver\lib\we
bdriver.js:414:17)
at Navigation.to (C:\Users\username\node_modules\selenium-webdriver\lib\webd
river.js:1042:25)
at Driver.get (C:\Users\username\node_modules\selenium-webdriver\lib\webdriv
er.js:832:28)
at Object.<anonymous> (C:\Users\username\node_modules\selenium-webdriver\exa
mple\google_search.js:46:8)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
Did I do anything wrong? Can anyone tell me why the offical sample is not launching firefox? Thanks!
I had the same error-message when trying to run a C#-application with Selenium 3.0.0.
The problem was that I was using the x64 Geckodriver.exe. After downloading and copying the 32bit version to my bin-folder, everything worked well.
-Robert

Categories

Resources