npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Storing multiple NPM libraries/packages in one Git repo

I am trying to install an NPM library which is not stored at the root of a Git repo.

imagine I have 3 npm packages in this git repo

/root
  .git/
  nodejs/ 
    libA/package.json
    libB/package.json
    libC/package.json

is there a way to install libA or libB or libC and reference them in a package.json dependencies list?

For example,

"dependencies": {
  "libB": "github.com/org/root/nodejs/libB#master"
}

but when I tried that, it didn’t work. The error was:

npm ERR! code ENOPACKAGEJSON


I do not believe there is currently a way to install directly from subfolder on github.

(There is certainly interest in being able to: long locked thread https://github.com/npm/npm/issues/2974 and long closed thread https://www.bountysource.com/issues/238111-allow-subdirectories-within-git-repos-in-npm-install/, but be warned there is some unconstructive comments mixed in with the discussion.)

You do have other options, like publishing the modules to an npm repository, or installing from a local folder, or for development using npm link, and even combining into a script to npm install package from github repo subfolder by hand.