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?
(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.
Bear With me for another quote...
As far as the bundledDependencies:
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 anotherpackage.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:
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 calledpackage
orvendor
and then placing the modules in there, in those you can edit thepackage.json
and bundles their dependencies to your hearts content. Be sure though that you do not ignore any files or folders under youvendor
orpackages
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.