openbci-archive / OpenBCI_NodeJS

Node.js SDK for the all OpenBCI Biosensor Boards
https://www.npmjs.com/package/openbci
137 stars 52 forks source link

Modules not importing correctly... #17

Closed andrewjaykeller closed 8 years ago

andrewjaykeller commented 8 years ago

Several developers have complained that the module is not requiring properly. The following do not import in the entry file: var k = require('./OpenBCIConstants'); var OpenBCISample = require('./OpenBCISample'); var serialPort = require('serialport');

andrewjaykeller commented 8 years ago

Found this: https://discuss.atom.io/t/cant-use-app-module-in-render-process/17326/3 Which leads me to thinking we might have to use this: https://github.com/atom/electron/blob/master/docs/api/remote.md

Not sure just digging

andrewjaykeller commented 8 years ago

Thinking this might be a bug with electron, closing here and opening over on OpenEXP

andrewjaykeller commented 8 years ago

So when i use the module in my program, i find the problem to come from v8. The function that throws the error is called Module._resolveFilename and it takes two inputs, a request and a parent. The problem is that v8 is looking for "./openBCISample" in paths"/Users/ajk/Thinker/client" versus in the node_module. screenshot 2016-01-16 09 51 30

teonbrooks commented 8 years ago

I'm sorry but I don't understand what the error is that is related to loading the constants.

andrewjaykeller commented 8 years ago

I have three .js files in the project:

All three are module.exports and all three are at the same level in the same directory. In openBCIBoard I have to require at least openBCISample so:

var openBCISample = require('./openBCISample');
var k = openBCISample.k;

However THIS issue comes from when v8 is trying to load openbci-sdk at runtime in say OpenEXP and when it get's to the line

var openBCISample = require('./openBCISample');

It throws the error cannot find module ./openBCISample because there is no file called ./openBCISample in the main project directory of OpenEXP. Essentially v8 is looking for a module called openBCISample in the node_modules in the root project directory because this file actually exists in node_modules/openbci-sdk

teonbrooks commented 8 years ago

ah, got it. because it's not properly interpreting local imports

andrewjaykeller commented 8 years ago

Yes!!! Need to figure out how to do that!


AJ Keller Founder & CEO Push The World LLC Work: (843) 471-0039 Cell: (203) 733-4538

Warning: The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and destroy this material.

On Jan 17, 2016, at 6:03 AM, Teon L Brooks notifications@github.com wrote:

ah, got it. because it's not properly interpreting local imports

— Reply to this email directly or view it on GitHub.

andrewjaykeller commented 8 years ago

thanks to @tashoecraft we are closing this!