Jump to content

Node Error "Cannot find module 'tinkerforge'"


rwblinn
 Share

Recommended Posts

Hi,

 

tried to run on a Raspberry Pi with Master Brick, Wifi Ext 2.0, Ambientlight the ExampleSimple.js.

When running from the commandline $node ExampleSimple.js, received error:

module.js:340

    throw err;

          ^

Error: Cannot find module 'tinkerforge'

 

The line in ExampleSimple.js not changed:

var Tinkerforge = require('tinkerforge');

 

Installed the javaScript bindings using npm. Steps taken as user Pi with install message.

cd /home/pi

sudo npm -g install tinkerforge

tinkerforge@2.0.9 /usr/lib/node_modules/tinkerforge

 

When adding the full path to require('/usr/lib/node_modules/tinkerforge') it is working.

 

How to setup without the need to add the full path in require.

 

Any help appreciated.

 

Link to comment
Share on other sites

I had the same behaviour. After I installed the Tinkerforge modules globally, it was finally located in e.g. /usr/lib/node_modules.

But its needed to add this location in NODE_PATH var to env in Linux like

# export NODE_PATH=$NODE_PATH:/usr/lib/node_modules
# env
...
NODE_PATH=:/usr/lib/node_modules
...

 

Ref.: http://www.tinkerunity.org/forum/index.php/topic,2216.msg14527.html#msg14527

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...