Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8177913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:38:22+00:00 2026-06-06T23:38:22+00:00

I have several apps in node that all share a few modules that I’ve

  • 0

I have several apps in node that all share a few modules that I’ve written. These modules are not available via npm. I would like to be able to share freely between apps, but I don’t want to copy directories around, nor rely on Git to do so. And I’m not really big on using symlinks to do this either.

I would like to arrange directories something like this:

app1
 server.js
 node_modules
  (public modules from npm needed for app1)
 lib
  (my own modules specific to app1)

app2
 server.js
 node_modules
  (public modules from npm needed for app2)
 lib
  (my own modules specific to app2)

shared_lib
 (my own modules that are used in both app1 and app2)

The problem I’m seeing is that the modules in shared_lib seem to get confused as to where to find the modules that will be in the node_modules directory of whichever app they are running in. At least I think that is the problem.

So….what is a good way to do this that avoids having duplicates of files? (note that I don’t care about duplicates of things in node_modules, since those aren’t my code, I don’t check them into Git, etc)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:38:24+00:00Added an answer on June 6, 2026 at 11:38 pm

    I’ve got this working by having node_modules folders at different levels – node then automatically traverses upwards until it finds the module.

    Note you don’t have to publish to npm to have a module inside of node_modules – just use:

    "private": true
    

    Inside each of your private package.json files – for your project I would have the following:

    app1
     server.js
     node_modules
      (public modules from npm needed for app1)
      (private modules locally needed for app1)
    
    app2
     server.js
     node_modules
      (public modules from npm needed for app2)
      (private modules locally needed for app2)
    
    node_modules
      (public modules from npm needed for app1 & app2)
      (private modules locally for app1 & app2)
    

    The point is node.js has a mechanism for dealing with this already and it’s awesome. Just combine it with the ‘private not on NPM’ trick and you are good to go.

    In short a:

    require('somemodule')
    

    From app A or B would cascade upwards until it found the module – regardless if it lived lower down or higher up. Indeed – this lets you hot-swap the location without changing any of the require(…) statements.

    node.js module documentation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have several apps that run on a Windows 2003/2008 server. Some of these
I have several iOS apps that all use the same subscriptions to supply functionality
I have seen several apps that make use of a UISplitViewController inside a tab.
I have several apps which I wrote using the standard SDK. They all connect
I have several iOS apps on the market and in all of them I
We have several java application server running here, with several apps. They all log
I have several files that I am displaying via UIWebView. I want to provide
I've built several apps in rails that have submissions that you can vote on.
I have several apps that I work on and like to distribute to friends
I have several apps that I'm trying to merge into a single suite: 2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.