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

  • Home
  • SEARCH
  • 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 8373847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:47:00+00:00 2026-06-09T14:47:00+00:00

It seems that NPM pack, and by extension, nodejitsu, do not like my node_modules

  • 0

It seems that NPM pack, and by extension, nodejitsu, do not like my node_modules folders. :*(

I currently am building a web app.

My web app’s project folder structure is as follows:

Root

Engine(folder)                      Server(folder)    readme.md     package.json

(Multiple Folders) (folder)(folder) node_modules(folder)

                   easyimage,mongodb,mysql(folders)       socket.io (folder)

       node_modules(folder, NPM Pack ignores this)           node_modules(folder, NPM Pack ignores this)

                                                       Socket.io-client (folder, NPM Pack ignores this)

I hope everyone can see this structure alright!

The problem I am having is that when I run NPM Pack at the root directory, the entire directory structure is packed correctly, except for all of the node_modules folders below the first node_modules folder.

It is as if NPM pack completely ignores those node_modules folders. (The one below socket.io for instance).

Due to the fact NPM pack ignores these npm folders, jitsu is also ignoring them and I can’t get my web app started.

How can I get NPM pack/nodejitsu to correctly package all of the node_modules folders correctly?

My current package.json file, at the root directory, looks like follows:
http://pastebin.com/SAU6rwb5

As you can see, I have attempted to use bundleDependencies to tell NPM Pack that I am trying to include some node_modules folders (modules?), but pack still ignores all of them… Also, if i include anything under “dependencies”, NPM start creates a new (??) node_modules folder at the root directory… but at the root directory nothing needs node_modules… as you can see node_modules are used inside of the server folder.

How can I get NPM Pack to recognize the files and folders inside of all of the node_modules folders and pack them correctly?

  • 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-09T14:47:01+00:00Added an answer on June 9, 2026 at 2:47 pm

    (jump to last paragraph if you want a really easy solution)

    I’m having a hard time understanding your app structure. I think I get what your trying to do though.
    From https://npmjs.org/doc/folders.html , it actually goes into detail about when and why sub modules will or wont show up.

    When installing locally, npm first tries to find an appropriate prefix folder. This is so that npm install foo@1.2.3 will install to the sensible root of your package, even if you happen to have cded into some other folder.

    Starting at the $PWD, npm will walk up the folder tree checking for a folder that contains either a package.json file, or a node_modules folder. If such a thing is found, then that is treated as the effective "current directory" for the purpose of running npm commands. (This behavior is inspired by and similar to git’s .git-folder seeking logic when running git commands in a working dir.)

    If no package root is found, then the current folder is used.

    When you run npm install foo@1.2.3, then the package is loaded into the cache, and then unpacked into ./node_modules/foo. Then, any of foo’s dependencies are similarly unpacked into ./node_modules/foo/node_modules/….

    Bear With me for another quote…

    Cycles are handled using the property of node’s module system that it walks up the directories looking for node_modules folders. So, at every stage, if a package is already installed in an ancestor node_modules folder, then it is not installed at the current location.

    Consider the case above, where foo -> bar -> baz. Imagine if, in addition to that, baz depended on bar, so you’d have: foo -> bar -> baz -> bar -> baz .... However, since the folder structure is: foo/node_modules/bar/node_modules/baz, there’s no need to put another copy of bar into .../baz/node_modules, since when it calls require("bar"), it will get the copy that is installed in foo/node_modules/bar.

    This shortcut is only used if the exact same version would be installed in multiple nested node_modules folders. It is still possible to have a/node_modules/b/node_modules/a if the two "a" packages are different versions. However, without repeating the exact same package multiple times, an infinite regress will always be prevented.

    As far as the bundledDependencies:

    Upon publishing [this also applies to packing], npm will look in the node_modules folder. If any of the items there are not in the bundledDependencies array, then they will not be included in the package tarball.

    I take this to mean that it will only bundle the listed modules in ./node_modules/ and specific sub-modules for a ./package.json . Then of course as written above, it recursively walks down the directory tree again… so if it sees another package.json file in this directory npm will look and see if that has any bundled deps to include in the pack.

    So as I understand it right now, since you have no packages in your base directory, your bundled dependencies in package.json doesn’t do anything, and actually having items in your bundledDependencies field does more harm than good.

    To fix you need to edit the package.json files to include these bundles at each level.

    I have had this issue before when trying to get a packed then unpacked meteor app working on nodejitsu. I solved it in a different way. In the root folder of my app I included all of the top level node modules and explicitly set their version in my package.json file.

    From what I understand your file structure is such:

        app
        +-- Engine
        +-- Server
        |   +-- socket.io
        |   |   `-- package.json
        |   |   +-- node_modules
        `-- readme.md
        `-- package.json
    

    If this is so then you need to be editing the package.json under socket.io to include the bundled deps you want. Generally though you can trust the package maintainers to keep valid versions.(but in this case you can’t?)

    As for Socket.io-client not being packed that’s a result of it being a dependency of socket.io.

    If I was to suggest a way for you to make this easier for yourself, i’d suggest you to, in your MAIN top level package.json file, to include the dependencies you need for your app @ the specific version you need. If you need them bundled for some reason, add them into the bundled section, if you need sub modules at a different version than what the author intended. Consider making a folder called package or vendor and then placing the modules in there, in those you can edit the package.json and bundles their dependencies to your hearts content. Be sure though that you do not ignore any files or folders under you vendor or packages directory with .npmignore or .gitignore files.

    Alternatively, if this is too difficult (editing all theses files and specifying certain versions can be a pain) I’d suggest hosting your vendor packages some where where you could download them with a script, and then execute this script in the postinstall part of your package.json (take a read at https://npmjs.org/doc/scripts.html … you would add this in the same section you have your "start" script.

    I hope that clarifies things.

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

Sidebar

Related Questions

Seems that there are not much work done on Haskell for web. People uses
Seems that requirements on safety do not seem to like systems that use AI
Seems that a site I made for fun does not like to work in
It seems that it is not advisable to use <meta http-equiv=REFRESH CONTENT=3;url=url> for redirects
It seems that this handy Quick Access window does not show the items available
It seems that, when using the following syntax in a C# project's AssemblyInfo.cs file,
Seems that web.xml for a servlet has an element called <enabled>false</enabled> that can be
Seems that when i create an object, the time is not correct. You can
Seems that it may not be possible, but hey I might as well ask,
It seems that when my JSP encounters an error like a misspelled variable name

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.