0

I've begun using Node.js to make web applications. It's really awesome. I've come across a few modules that I want to incorporate into my build. I can work with the modules in Terminal after a global npm install. When it comes time to add them to my application, I have no idea how to go about placing them in my directory structure and I haven't found any good documentation on this. My typical node.js directory is:

  • ROOT

    • Server

      • server.js
      • node-modules
    • Client

      • index.html
      • css -main.css
      • javascript -main.js -jquery.js

My process for installing the modules has been:

I cd into my Server file and run npm install Then I go to my package.json file and include the module in the dependencies

{
  "name": "application-name",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app"
  },
  "dependencies": {
    "express": "3.1.0",
    "jade": "*",
    "stylus": "*",
    "<node-module-here>": "1.0.x",

  },
  "engines": {
  "node": "0.10.0",
  "npm": "1.2.14"
},

}

After that, I head over to the server.js file I add:

module.exports = require('<path_to_node-module_lib>');

When I run functions that are dependent on the modules on the Client side (functions that work in Terminal), I don't receive an error but the function won't run. Because I'm not receiving errors I have no idea about how to debug. If anyone can recognize some fatal flaw in my structure or implementation and can offer some recommendations, I offer my first born.

terra823
  • 92
  • 1
  • 10
  • Can you see the modules in the node_modules directory?I like to keep a separate directory for my node_modules inside my project directory. – Akshat Jiwan Sharma Mar 29 '13 at 03:38
  • yeah, the node-modules directory is kept in my Server directory on the same level as the server.js file. i can see the modules in the node-modules directory. – terra823 Mar 29 '13 at 03:43
  • Then I don't think you need ''.For example if you have installed express module require('express') is enough.There is no need to give the full path for it. – Akshat Jiwan Sharma Mar 29 '13 at 03:45

0 Answers0