peter-murray / node-hue-api

Node.js Library for interacting with the Philips Hue Bridge and Lights
Apache License 2.0
1.19k stars 145 forks source link

Chai problem, cant find module #8

Closed bwired-nl closed 10 years ago

bwired-nl commented 10 years ago

Hi Thanks for the great work I have a problem If i run bridge-connect i get an Chai error

Module.js 340 throw error Cannot find module 'chai' At function module _resolvefilename (module.js 338:15) At function module _load (module.js 280:15) Etc.

Hope you can give a hint Thanks pieter

peter-murray commented 10 years ago

Hi,

Have you run npm install from the root directory of the project? That should resolve all the dependencies for you. Please note that the tests are fairly specific to my bridge and set up, so there will be quite a few that will not run correctly for you.

bwired-nl commented 10 years ago

Hi Peter Im running it in the Rasp, just starting with it. the sample files i can handle, thanks im installing from Home/PI directory and i see the node-hue-api neatly in the node_modules directory along with all other node modules i use. in node-hue-api is directory test. is start with node "node_modules/node-hue-api/test/bridge-connect" and then the above errors comes thanks very! Pieter

peter-murray commented 10 years ago

Mocha and Chai are devDependencies so that means when you use them in your project as a module, i.e. it appears under the node_modules directory of your project, then these will not be fetched and installed.

This is how node and npm work as you are not normally interested in the development dependencies when using a library in another project. For more information on this, take a look at https://npmjs.org/doc/json.html#devDependencies

If you want to run the tests, then it is probably best that you clone the git repo yourself to another directory not under node_modules, run npm install on that and you will resolve the test frameworks as you desire. After that you could then run mocha test/bridge-connect to run the test you mentioned above.

bwired-nl commented 10 years ago

thanks Peter that worked, dependencies Chai en Mocha installed but my next error is now:

Refference error: Describe is not defined describe("Hue API", function () { (line 6

The Hue is fully working, checked with Api tool hope you have some more patience :-) learning a lot but installation errors are still a bridge to far for me

Thanks

peter-murray commented 10 years ago

The tests are written in Mocha, so that only way that you can run them is via Mocha itself. Unless you have already installed Mocha globally, done using npm install -g mocha, then you will have to run the following; node node_modules/.bin/mocha test/bridge-connect.js to execute the bridge-connect tests.

I use a make file to run all the tests via npm, which can be invoked using npm test, but of course a number of these will fail for you as the some of the tests are specific to my bridge and setup.

bwired-nl commented 10 years ago

thanks Peter got some thing working now great!

peter-murray commented 10 years ago

Good to know, happy programming